RPi – Static IP Address on Wifi

There is a GUI tool in the desktop called “wpa_gui” which can be used to connect to the wireless network provided you have a supported wireless card attached to the RPi. However, if I want to run a headless RPi I would need a static IP address. Unfortunately “wpa_gui” does not provide me a means of configuring static IP address on the “wan0″ interface and my ADSL router does not support associating a static IP address with a MAC Address. This means I have to use static IP address configured on my wireless interface on the RPi and have to do it the old fashioned way (read I am loving it).

Open up the “/etc/network/interfaces” file and make the following entries. The commented lines are the one’s which were added by the “wpa_gui” and we don’t need them. If you have little Debian experience, you will find these lines self explanatory:

auto lo
iface lo inet loopback

#auto eth0
iface eth0 inet static
address eth0

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-ssid "My SSID"
wpa-passphrase "My Passphrase"

I have added a static IP address configuration line for the eth0 interface also, so that in case someday I connect my RPi to physical connection I will just bring my eth0 interface up and have an IP address. The reason I have commented the “auto eth0″ line is because in case a physical interface is up, the default route of the system is always through the physical interface i.e eth0 in this case. So, if my WiFi is up, I want my packets to go in/out through WiFi by default and not through “eth0″ (by the way it does not matter if you have connected the cable physically or not, if the physical interface is up, it is the default route out). Of-course we can prevent that, but it is going to be a little bit complicated, so we are going to just comment out auto line to make sure that the “eth0″ does not come up. It is also possible to have both “eth0″ and “wlan0″ run simultaneously, but again it is a bit complicated for this post and I do not need that anyway.

Now you can restart the networking or reboot the RPi and your WiFi should come up with the static IP address.

Posted in RaspberryPi | Tagged , , | Leave a comment

Setting up a Git Repository on A Remote Server

Git is a wonderful distributed version control system and we can have a personal repository quickly set up without any technical difficulties. However at times we may need to work on shared development model where multiple people need commit access to the code. In such cases we would need a centralized repository store.

By following  the given steps we will be able to set up a shared git repository accessible over SSH.

  • First a user needs to be created to hold the git repository (multiple repositories can also be set up under the same git user). Next a password need to be set up for the same user. Since this user will  never log on using shell, a password which is secure, random, very long string is a good option.
$ sudo /usr/sbin/useradd -c "Git Version Control" -d /home/git -m -s /bin/bash git
$ sudo passwd git
  • Next login as git user and create the project directory to hold the repository and then initialize that directory as a barebones (blank) git repository
$ mkdir -p /home/git/projects/myproject1.git
$ cd /home/projects/myprojects.git
$ /usr/bin/git --bare init
  • Set up the .ssh directory for the git user to hold the authorized_keys file with the public ssh keys for the user allowed to log in a git user and access the repository
$ cd /home/git
$ mkdir .ssh
$ chmod -R 700 .ssh
$ touch .ssh/authorized_keys
$ chmod 644 .ssh/authorized_keys
  • Finally change the shell of the git user to git-shell so that interactive logins for the user are not possible and only selected remote git commands are allowed.
$ /usr/bin/chsh -s /usr/bin/git-shell

Add the public key of the user(s) to the authorized key file. These users will be able to access the repository. Now all that needs to be done is to clone the repository and start working. Following command can be used to clone the repository on a *nix box. The 7652 is the port number where ssh daemon is listening. If your port is the default, 22, you can skip this port number.

$ git clone ssh://git@myhost.mydomain.com:7652/home/git/projects/myproject1.git/
Posted in FLOSS | Tagged , | Leave a comment

Time-zone Setting in Linux and BSDs from Shell

Often the default time-zone in a linux and bsd system does not match our preferences. On a system which we have installed ourself, we may have selected the appropriate time-zone during installation, but as systems administrators we often get our hands on a system which is pre-installed and after taking over we want to change the time-zone to something which we are comfortable understanding and co-relating various system events in the time of our comfort.

The time-zone of  the system is determined by a file called “/etc/localtime”, which a binary file. In order to change the time-zone, we need to replace this file with an appropriate file of our time-zone. All time-zone files are found in “/usr/share/zoneinfo”.

On some systems “/etc/localtime” is a copy and in some cases a hard link of one of the time-zone found in “/usr/share/zoneinfo” directory. In OpenBSD, “/etc/localtime” is a symlink to one of the files in “/usr/share/zoneinfo”. I prefer the symlink approach, you can pick any of the methods to make appropriate “/etc/localtime” file available.

In order to change the time-zone of my system from UTC to IST, I did the following.

$ sudo ln -sf/usr/share/zoneinfo/Asia/Kolkata /etc/localtime

In case you accidentally delete the “/etc/localtime” file, the timezone of the system reverts to UTC and upon having the correct file present again, it will reflect the correct timezone again. See below (I did this on a RHEL 6 machine) -

$ date
Wed Dec 18 13:56:05 IST 2013
$ sudo rm -f /etc/localtime
$ date
Wed Dec 18 08:36:29 UTC 2013
$ ls -l /etc/localtime
ls: cannot access /etc/localtime: No such file or directory
$ sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
$ date
Wed Dec 18 14:07:03 IST 2013


Posted in FLOSS, Tips/Code Snippets | Tagged , , , , , , | Leave a comment

FreeBSD 9.1 on Thinkpad T420

beastieVery recently I was thinking of trying FreeBSD operating system on a laptop as a desktop system. FreeBSD is an excellent UNIX class of operating systems primarily used as a server on internet. Among other things the operating system posses excellent memory management features, ZFS and LLVM etc.

I have installed various BSD class of operating systems earlier also, but when I installed FreeBSD 9.1 this time, I noticed that the default disk partitioning options have changed in the installer. By default if the automatic partitioning option is chosen, FreeBSD creates GPT (GUID Partition Table). I decided to proceed with all default options except the timezone settings were changed to IST.

At the end of the install, the system refused to boot from the hard disk. I thought this is because the BIOS may be configured to use the UEFI (Unified Extensible Firmware Interface) being configured in BIOS as the laptop had windows 7 installed in it. I tried changing the setting to – disable, EUFI/legacy, legacy – but still the laptop did not boot. Upon my research on the internet I came across – https://wiki.freebsd.org/UEFI. Here it was mentioned that -

Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive. This should be fixed as of r251588, to be confirmed.


fdisk /dev/sda0

from the live mode in FreeBSD confirmed that there is an MBR partition created and the flag 80 (active) has been set on it. I booted from a linux CD and ran

fdisk -l /dev/sda0

to confirm that this is indeed the case. So I used linux fdisk to remove the active flag (toggle option), but this did not help me.

At this moment I decided to drop this issue here and take the easy way out in order to get the operating system installed. During the installation this time I chose manual partitioning -

  • deleted all partition
  • changed the partitioning scheme to MBR (the default was GPT)
  • created a FreeBSD partition on it with further two partitions (slices) within the FreeBSD disk area
    • one as type freebsd-swap
    • other freebsd-ufs (mounted at /).

During the end of the installation an option to go to shell for additional installation is provided. I selected that option and then ran the


utility and selected options as follows -

sysinstall -> Configure -> Packages -> FTP -> Main Site

Selected all the desired software and finished the installation. The reboot took me straight to FreeBSD.

Enabling UTF-8

The available locales can be checked using the locale command. In order to find out the UTF-8 locale which are installed -

# locale -a | grep UTF-8|grep US

In order to add the support for this locale, following lines need to be added in /etc/login.conf -


Finally run the -

#cap_mkdb /etc/login.conf

Now in order to use these following two environment variables can be set -


Installing X windows and Windows Managers

Since I wanted to get a graphical desktop on the laptop, I need to install X windows, a window manager and some other graphical tools like browser etc.

# pkg_add -r x11 ratpoison awesome stumpwm firefox

Configuring X and starting is done as below -

# X -configure
# cp /root/xorg.conf.new /etc/xorg.conf
# cat ~/.xinitrc
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
exec /usr/local/bin/ratpoison

Following two lines needs to be added to


for the X to work correctly -


and then finally


to launch the X. May be later on I will install one of the display managers to facilitate graphical login.

So I am ON with freebsd and now I can start learning/exploring this further and may be try some of the other BSDs along with this as multiboot. I have not really worked on BSDs from quite sometime. I expect this to be a good refresher.

Posted in FLOSS | Tagged | Leave a comment

Raspberry Pi And Me

I bought a Raspberry Pi somewhere in March this year. After a very hectic schedule, I managed to find few hours yesterday evening to explore it. I bought the following accessories in order to use it -

  • A Belkin 4-port powered USB Hub
  • Netgear Wireless USB Micro Adapter
  • Dell LCD Monitor (wall mounted). This was a cheap VGA based
  • HDMI to VGA converter. Raspberry Pi has HDMI port, so I needed a converted to attach it to my monitor.
  • A USB A to USB Micro cable to power the Raspberry Pi
  • iBall Wireless USB Keyboard and Mouse
  • 32 GB MicroSD card with a Micro SD to SD card adapter

The LCD and USB hub occupies the power sockets. The Raspberry Pi is powered from the USB hub using a USB A to USB micro cable. The two USB ports on the Raspberry Pi have been occupied with the USB Hub and iBall wireless adapter for Keyboard and Mouse. The Netgear wireless adapter has been connected to the USB Hub and so is my external HDD for extra storage.

I am using Raspbian (a variant of Debian meant for Raspberry Pi), distributed by the the Raspberry Pi Foundation, which is a little different from the images by Raspbian project.

I had (and still have) some problems with booting while my monitor is connected, perhaps because the HDMI to VGA converter is drawing too much power from the RPi. I need to look into it later.

The initial idea of using it as a light weight desktop environment is not going to work because of lack of flash support, and speed related issues. Although HTML 5 videos can be played, they need a separate configuration for the installed browser Midori. More on that configuration later.

In general it is a bit slower because all the applications are not designed to use the GPU effectively and the processor is too slow by even the standards of a high end mobile phone. Although I am typing this blog post on RPi using Midori web browser, I can feel the slowness while trying to add pictures as an attachment which needs JavaScripts to be processed at client side. I tried opening up the Yahoo Mail earlier today, it worked but it was very slow, almost unusable.

However, I have observed that it is ok for teaching programming to kids and also I can perhaps run it as a headless media player using XBMC and so on. For now I have installed Perl, Python and FreeBasic programming environments on this. All of which should work through command line effectively.

I will make further posts sharing my experience on this credit card size device.

Stay tuned.

Posted in RaspberryPi | Tagged | 1 Comment