Thursday, December 31, 2009

Disabling splash screen in ubuntu 9.10

The splash screen is shown when you boot up ubuntu. You can stop showing it and display lot of details about your boot process as below.
Run gedit in su mode and edit the file /etc/default/grub
 sudo gedit /etc/default/grub
Locate the line that shows the floolwing
Remove quiet and splash
Then save and close out of your editor

Run the following command to update grub.
sudo update-grub
This may take a couple of minutes with out any visible feedback. You will come back to bash prompt eventually.
After the previous command is finished you should be able to reboot and when you boot up you will have a verbose boot with out a splash screen. You can experiment with "splash" alone removed from the config file.

Sunday, December 13, 2009

Mounting Remote Directories with SSHFS

Recently, I was demonstrating ssh tunneling to some of my students. One of them asked me how they access remote directories in GUI. This can be achieved in several ways. Let us try mounting via ssh.

Install the sshfs package on the machine you want to mount the remote directory.

$ sudo apt-get instlall sshfs

You need ssh server running on the remote machine and you must have a valid username and password on that machine.
In the example below, I am assuming that you have an account named ubg on a remote_server . Replace remote_server with its IP address. /home/ubg/remote is the local folder into which the remote folder will be mapped. Now let us mount the remote directory.

$ sudo sshfs ubg@remote_server: /hume/ubg/remote

This will mount the home folder of the user ubg on remote_server to the folder /home/ubg/remote on the local machine. You can mount any folder on which you have read permission to the local machine. See this example.

$ sudo sshfs ubg@remote_server:/usr/share/doc /hume/ubg/remote

Now, you can access the remote folder via nautilus like a local folder.

You can unmount the remote folder with

$ sudo fusermount -u /hume/ubg/remote

Tuesday, December 1, 2009

Some wget tricks

The wget is a command line utility that can download files from web servers and FTP servers.
For example , you can download the DVD image of Karmic Koala using the following command.

$ wget

If an FTP server requires a login and password, you can enter that information on
the wget command line in the following form.

$ wget

You can use wget to download a single web page as follows:

$ wget

A file named index.html will be created in your current directory

If you open this index.html in a web browser , you will find some of the links broken especially images. . To download all the images and other elements required to render the page properly, -p option can be used.

$ wget -p

This will create a folder named with index.html in it.

But if you open the resulting index.html in your browser, chances are you will still
have all the broken links even though all the images were downloaded. That’s because
the links need to be translated to point to your local files. So instead, do this:

$ wget -pk

Sometimes an HTML file you download does not have an.html extension, but ends
in .php or .cgi instead. . If you wget files from such a site , your browser will complain when you try to open the file. To solve the problem , you can ask wget to append .html to such files using the -E option:

$ wget -E

I use the following command line to keep a usable copy of the website on my hard disk.

$ wget -mEkK

Saturday, November 28, 2009

Moving a MySQL Database To Another Server

Here is a simple command line tip for moving a mysql database from one server to another.

 mysqldump  [mysqldump_options] |
gzip -c | ssh user@remotehost "gunzip -c > mysql [mysql_options]"

Thursday, November 12, 2009

Installing Google's Go Language on Ubuntu

GO language promoted by google is a new system programming language said to be expressive, concurrent, garbage-collected. The language is still very young and there is no ready made package available for ubuntu. You can install it and try out the features from the version control repository of go .

Let us see how you can do this. I did it on ubuntu 9.04.

1) Install Pre-requisites on ubuntu.

You need gcc and some supporting software like bison to compile go. Install the following.
 $ sudo apt-get install bison gcc libc6-dev ed.

The go repository uses mercurial version controls system .
Install mercurial with the following command.

$ apt-get install mercurial

2 Set up the environment variables.

I am assuming that you are planning to install go under a folder
named go in your home directory.

In my case it is /home/fermi/go

Create it with
$mkdir go

Now create another direcory inside go .

$ mkdir go/bin

The above directory will contain your go compiler.
Next, you have to set u several variables.

$ export  GOROOT=/home/fermi/go/hg
$ export GOOS=linux

$ export GOARCH=386
$ export GOBIN=/home/fermi/go/bin

( Note: You need not create the folder hg. You can also add the above
four lines along with the PATH variable below to the .bashrc file
if you are planning to use go regularly.)

Update your PATH variable .

$ export PATH=$PATH:$GOBIN

Check the environment variables with.
 $ env | grep '^GO'

I got like this.


3) Grab the source code from mercurial

$hg clone -r release $GOROOT 

It created
/home/fermi/go/hg and downloaded several files to it.
To build the Go distribution run.

4) Compile Go

$ cd $GOROOT/src
$ ./all.bash

Now wait for some time. The compilations will proceed and will be
completed with the following message

--- cd ../test
N known bugs; 0 unexpected bugs

5) Test go
Your go language system is ready to go.:D
Now let us write a hello world program and test it.

Create the following program in your favourite editor and save it as hello.go

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")

To compile hello.go run.
 $ 8g hello.go

The above command produced and intermediate file hello.8.
Next you have to link it.
$ 8l hello.8

The executable is placed as 8.out. Finally run the executable.

Enhancing terminals with byobu on Ubuntu 9.10

Byobu is a Japanese term for decorative screens . A Japanese byobu screen looks as below.

You can achieve similar decorative effects on your gnome terminal or xterm , or Konsole with Byobu software available from ubuntu launchpad. Infact, the new ubuntu 9.10 ships it by default. On earlier versions of ubuntu you can install byobu from the PPA here.

On my jaunty box , I added the following to /etc/sources.list and imported the key form the PPA and installed it via apt,

For trying out byobu , open a terminal and type

$ byobu

your terminal will immediately change to the following screen.

The bottom line on the above picture indicates the present status of your system. It displays several useful parameters. Byobu can be customised to display several other informatiin.

Infact ,byobu is an enhancement to GNU/Screen. So, all commands applicable to GNU/ screen will work with byobu. If you are not familiar with screen look at this page for some additional information

Most of the settings of byobu are stored in a hidden directory named .byobu under your home folder. Most ot these settings can be modified from byobu itself. For customising byubu, press F9 . You will get the following screen.

You can change the look and feel of your terminal as shown in the screen-shots below.

For me the status notifications on the last line is very useful For adding additional parameters Press F9 and select status notifications , you will get the following screens. Choose whatever parameter you want to display as your default status line.

To start byobu automatically when ever you launch a terminal on Karmic Koala desktop, select
the last option as shown below. ( Be careful as screen sessions can become background processes. I suggest you GNU/screen documentation )

and press enter.

Now click on edit->> Profile Preferences-> Title and Command on your gnome-terminal and tick Run command as login shell.

Byobu will be launched automatically next time when you start a terminal.

Wednesday, November 11, 2009

Remastering Karmic Koala

My colleague and fellow blogger Shibu Varkala has remastered the new ubuntu karmic koala . He has written a small write up. Please read it here.

Thursday, October 29, 2009

Ubuntu one on Karmic Koala

Ubuntu one is a free on line file sharing service offered by Canonical. The newly released ubuntu 9.10 has Ubuntu One tightly integrated with it. For using this service , you have to sign up with Ubuntu one. Click on this link and fill in the details to get a free account which can hold upto 2 GB. A mail will come to you mail account asking you to confirm the subscription.

Once you have completed the registration and confirmed , the ubuntu one account can be set up on your karmic koala desktop.

Click on Applications >> Internet and click Ubuntu One. The following window will pop up.

You can set the preferences for show icon ,connect on start and bandwidth.

The web browser will be launched and you will be taken the the launchpad website and asked to login. Once you login you will again be asked to confirm whether you want to add you computer to Ubuntu One. Once you agree, the Ubuntu one menu item will come under . See the picture below.

You can use this folder as any other normal folder on your computer.

This folder will be under your home directory. If you open a terminal and move to ~/ Ubuntu\ One/ folder, you can see the off-line contents on your hard disk. If you open the folder in nautilus, a special connect / disconnect button appears. You can use this to connect to the Internet and update your files on the Ubuntu one servers.

Thursday, October 8, 2009

Time Synchronization using NTP on Ubuntu

Network Time Protocol is used for synchronizing time among different computers on a network. There are several public NTP servers from which you can request current time and synchronise your machines clock the that of the server. Let us look at how this can be done on ubuntu 9.04.

Click on System->Administration-> Time and Date Click on unlock. You may have to enter your password to continue.

  • Select the configuration option Keep synchronized with Internet servers

  • You may get a dialog box informing you that NTP support has to be installed. Click on Install NTP Support . The necesary files will be downloaded from the repository.
    Once the download is complete Close the Time and Date pop up window. Run it once again from System->Administration-> Time and Date . You will get the following window.

    Click on Select servers.

    Put a tick mark on the selected server and close the window. The NTP client will start running depending on the configuration file /etc/ntp.conf. You can tweak this file for various time update options.


    Wednesday, October 7, 2009

    Accessing remote computers via XDMCP

    You can login to a remote computer via XDMCP if it is configured to allow XDMCP logins. I will explain how I did it on two Ubuntu machines running gdm.
    Suppose you have two machines A and B ( In my case both are running ubuntu 9.04 , you can try this on other distros too.) They are connected via Ethernet and they are on the same network. (At my end, machine A had an IP address of and machine B had an IP address of

    At machine A.

    Open a terminal and run

    $ sudo gdmsetup

    You will get the following screen.

    Select Remote tab.

    Change the style tab from remote login disabled to same as local.

    Close the window.

    At machine B

    Boot the machine and come to login screen. Click on options and select remote login via XDMCP. Wait for a moment you will see machine A in the list.

    Select Machine A from the list and click on connect button. You will get login screen of machine A.
    It is possible to login to remote machines on internet if you have good connectivity. You can add the host IP in the above box and connect to the remote machine to get the login screen.

    Tuesday, October 6, 2009

    Downloading Ubuntu 9.10 beta with zsync

    The ubuntu 9.10 beta iso images for various architectures are shipped along with zsync files for easy update of iso images from previous releases. This post will show how you can use zsync to save your bandwidth and time while you download the next version of the karmic koala.

    zsync is a file transfer program similar to rsync. zsync is optimized for distribution of files across Internet, with one file on a server to be distributed to thousands of down loaders.

    Recently ,I used zsync to update the iso image of karmic koala alpha6 to beta . This is what I did on my ubuntu Jaunty machine.

    $ sudo apt-get install zsync

    I had downloaded the alpha version of karmic koala and kept it as karmic-desktop-i386.iso in my home folder. For updating this image to the beta release I typed the following command.

    $ zsync -i karmic-desktop-i386.iso

    The above command will read karmic-desktop-i386.iso from my hard disk and compare it with the ubuntu-9.10-beta-desktop-i386.iso on the ubuntu servers and update the local image to new version.

    As per the release schedule for karmic, the release candidate and final release are expected on 22nd and 29th of October 2009. Get ready with zsync for updating your beta iso to the final .

    ( Ubuntu provides jigdo files which can also be used to update the image)

    Friday, September 18, 2009

    Beating internet restrictions with ssh

    In most of our schools and offices several websites are blocked. Most of these offices and schools are using a proxy server such as squid along with squidguard or danceguardian to achieve access restrictions on users. Most often, the sys admins forget to block internet traffic using other protocols such as ssh , ftp etc. You can beat the web filtering scheme of your network administrator if you can access a machine on internet via ssh. Open ssh server can act as a socks proxy.

    So . install open ssh server on your home machine and leave it connected to internet. Note down the ipaddress of your home machine. If it uses DHCP , you can install some thing like dyndns client and keep track of the IP address. From your office/school connect to the home machine as below.

    $ ssh -D 2345 ipaddress _of_home_machine

    ( You can use any other unused port no. instead of 2345. You may not be able to connect to home if the admin has blocked ssh port on the firewall. You can try running ssh server at home on a different port)

    Open your firefox browser and select file=>preferences->advanced->network-settings. Fill in against the Socks host column and enter 2345 as port. Click ok to save.
    All your webtraffic will now be tunneled to your home machine beating the local proxy. Enjoy unrestricted internet.

    Wednesday, September 16, 2009

    How to install android sdk 1.6 on Ubuntu 9.04

    Google has recently released version android SDK 1.6. This tutorial will teach you how to install it on ubuntu 9.04.

    1 Installing Java
    Android SDK is built around Java . So, you have to install Sun Java before trying to install Android. Look at this post for details about installation of sun java development kit on ubuntu 9.04.

    2) Download android sdk. The current version ( 1.6 R1 ) is available as a tar.gz file from google. Look at this link . You will be prompted to accept android licence and if you accept it, you will be redirected to another link which will permit you to download the sdk. ( It is around 222MB)

    3) Unzip the tar.gz file .
    I unzipped it to my home folder with the following command

    $ tar -xzvf android-sdk-linux_x86-1.6_r1.tgz

    All the files were unzipped to a folder named android-sdk-linux_x86-1.6_r1
    If you look at the directory now , you will see the following files and folders.

    $ ls android-sdk-linux_x86-1.6_r1

    add-ons docs documentation.html platforms RELEASE_NOTES.html tools

    The tools for android development is under the tools directory.

    4) Test drive the android emulator

    Since all the android tools are kept under android-sdk-linux_x86-1.6_r1/tools, we must modify the PATH environment variable so that it includes the above directory too.Open a terminal and execute the following.
    fermi @Jaunty:~$ PATH=${PATH}:~/android-sdk-linux_x86-1.6_r1/tools
    fermi @Jaunty:~$ export PATH
    You can also add the above line to your ~/.bash_profile or ~/.bashrc , so that the setting is available always.

    My PATH variable looks like this after the above command.

    fermi @Jaunty:~$ echo $PATH

    Now you can test fire your set up . It is a good idea to keep all your android related files in a separate folder. I created a new folder named ANDR for experimenting. All the commands below are executed in that folder.

    The virtual phones created by android SDK are called AVDs ( android virtual device) .Let us start the experiment with a virtual SDcard and a Virtual Phone.

    Let us create a virtual SDcard

    $ mksdcard 2048M SDCARD
    If you look at the contents of the folder you will see a 2GB file named SDCARD

    Next, create an android virtual phone named FERMI_PHONE.

    $ android create avd -n FERMI_PHONE -t 2
    Android 1.6 is a basic Android platform.
    Do you wish to create a custom hardware profile [no]

    Press enter to choose no. You will get back the following message.

    Created AVD 'FERMI_PHONE' based on Android 1.6, with the following hardware config:

    Now start up android emulator.
    $ emulator @FERMI_PHONE -sdcard SDCARD

    Your virtual phone pops up as below. ( Another window which asks you to participate in a survey also pops up, you can close it.)

    Wait for a moment , your screen will change to the one shown below.

    You can press menu button to unlock the phone.

    You can flip the phone with CNTRL+F11

    Now let us browse on the android phone.

    5 )Starting development with SDK.

    The easiest way to start development on android is via eclipse. The eclipse version shipped with jaunty is some what old. ( Version: 3.2.2-5ubuntu3) . You need a later version for installing the ADT ( android Development tools ) for eclipse. I downloaded Eclipse 3.5 (Galileo) from the eclipse site and installed it . Then completed the following steps.
    1. Start Eclipse, then select Help > Install New Softare.
    2. In the Available Software dialog, click Add....
    3. In the Add Site dialog that appears, enter a name for the remote site (e.g., "Android Plugin") in the "Name" field.

      In the "Location" field, enter this URL:

      Click OK.

    4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
    5. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
    6. Restart Eclipse.
    Now modify your Eclipse preferences to point to the Android SDK directory:

    1. Select Window > Preferences... to open the Preferences panel
    2. Select Android from the left panel.
    3. For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.
    4. Click Apply, then OK.
    Now your development environment is ready.

    For running a hello world application, read this entry from the developers guide. Here is a screen shot of my hello world application.

    Happy Hacking.

    Ripping CD Music with cdparanoia

    cdparanoia is a command line
    audio CD digital audio extraction application. You can use use it for compiling music in a format suitable for your PC or mobile music player. cdrparanoia is available on almost all linux distributiions.
    On ubuntu you can install it with

    $ sudo apt-get install cdparanoia

    For trying out cdpaanoia ,put an audio CD in your cd drive and run the following command from a terminal.

    $ cdparanoia -vsQ
    Checking /dev/cdrom for cdrom...
    Checking for SCSI emulation...
    Checking for MMC style command set...
    Verifying CDDA command set...
    Table of contents (audio tracks only):
    track length begin copy pre ch
    1. 18295 [04:03.70] 0 [00:00.00] no no 2
    2. 16872 [03:44.72] 18295 [04:03.70] no no 2
    11. 17908 [03:58.58] 174587 [38:47.62] no no 2
    12. 17342 [03:51.17] 192495 [42:46.45] no no 2
    TOTAL 209837 [46:37.62] (audio only)

    The above output show the capabilities of your CDROM , wheither CDDA is supported, SCSI emulation is used etc. Cdparanoia extracts audio from compact discs directly as data, and writes the data to a file or pipe in WAV, AIFC, AIFC or raw 16 bit linear PCM.

    Here are some examples of cdparanoia command lines that I use.

    $ cdparanoia -B Rip tracks as WAV files by track name
    $ cdparanoia -B -- “3-5” Rip tracks 3-5 into separate files
    $ cdparanoia -- “3-7” myrip.wav Rip tracks 3-8 to one file (myrip.wav)
    $ cdparanoia -- “1:[40]-”
    Rip tracks 1 from 40 secs in to end of the CD
    $ cdparanoia -f -- “3”
    Rip track 3 and save to AIFF format
    $ cdparanoia -a -- “5”
    Rip track 5 and save to AIFC format
    $ cdparanoia -w -- “1” my.wav
    Rip track 1 and name it my.wav

    Monday, September 14, 2009

    Searching Ubuntu filesystem with (m)locate

    Ubuntu keeps a database of all the files in the file system at /var/lib/mlocate/mlocate.db. ( how this database is kept is dictated by /etc/updatedb.conf). The locate command
    allows you to search that database. ( On Ubuntu, the locate command is a symbolic link
    to mlocate. So you can also use mlocate )
    You can use locate command to find out commands, devices, man pages, data files, or anything else identified by a name in the file system.
    See the following example

    The results come back instantly, since
    the database is searched and not the actual file system. Before locate was available,
    most Linux users ran the find command to find files in the file system. locate is case sensitive unless you use the –i option. Here’s an example:
    $ locate -i cpuinfo

    The mlocate package includes a cron job that runs the updatedb command once per day to update the locate database of files.
    To update the locate database immediately, you can run the updatedb command manually.
    $ sudo updatedb

    Friday, September 11, 2009

    Songbird :The Open Music Player

    Songbird is an open source music player from the Mozilla stable. It is under active development and can be run on several platforms. Moreover, songbird offers several integrated services such as integrated music store, several fm and shoutcast station , concert tickets etc.

    For trying out songbird you can get source/binary from the songbird website. If you are on ubuntu, ready to use packages are available at getdeb.
    For installation , grab the deb corresponding to your version of ubuntu.
    On my Jaunty box I did
    $ sudo apt-get install songbird_1.2.0-1~getdeb1_i386.deb

    Song bird appeared under Application-Sound and Video->Songbird
    When I clicked on the menu item it showed me the songbird licence and proceeded to ask some configuration questions. Finally, I got the following screen and I started listening immediately,

    You can do anything that you do in rhythmbox. Songbird Rocks !!

    Wednesday, September 9, 2009

    How to remove a deb package manually

    Some times when you install a new deb package, the system will be broken. We may have to remove the package.
    For this , you can try the following. ( Assuming aspell is the broken package)

    # apt-get remove aspell

    #dpkg -P aspell

    #dpkg –force-all -r aspell

    These methods can also fail some time. Your only way out will be a manual removal of packages, which can be achieved as detailed below.

    a) Get a list of files from the package

    # # dpkg -L aspell

    b) Remove the files one by one.

    c) It is also suggested that you run

    # apt-get remove aspell

    after manual removal.

    Friday, August 28, 2009

    Deluge: A cross platform bittorrent client

    Deluge is a full-featured BitTorrent client for Linux, OS X, Unix and Windows. It has been designed using the client server model with a daemon process that handles all the bittorrent activity. The Deluge daemon is able to run on headless machines with the user-interfaces being able to connect remotely from any platform. Deluge features a rich plugin collection; in fact, most of Deluge's functionality is available in the form of plugins.
    Installation on Ubuntu
    As already mentioned , Deluge is available on a wide variety of platforms. For Ubuntu,Deluge is available in the universe repository. Cutting edge versions of Deluge is also available as a PPA via launchpad.
    For installation from PPA, add the following lines to /etc/apt/sources.list
    deb jaunty main
    Import the key from the PPA site.
    Install deluge
    $ sudo apt-get install deluge

    Screen shots.

    Tuesday, August 25, 2009

    command-not-found in Ubuntu 9.04 and 9.10

    command-not-found is a special package in ubuntu that give you some extra information when you type a command that is not installed on the command line. It will look inside the package database and suggest a possible package to install so that the command can be run. command-not-found is installed automatically when you install ubuntu 9.04.

    For example , I got this when I typed jed.
    $ jed
    The program 'jed' is currently not installed. You can install it by typing:
    sudo apt-get install jed
    bash: jed: command not found

    However when I type

    $ jid
    bash: jid: command not found

    The command -not-found hook neatly searches the package database and suggest a possible package for installation. The upcoming release of Ubuntu ( 9.10 aka Karmic Koala) will have spell checking incorporated into the command -not-found feature . It will suggest a list of possible packages even if you make a spelling mistake. See the following screen shot of my Karmic Koala Alpha 3.

    Controlling Services from Command line

    Before learning how to start, stop, and disable services from the command line, it's important to understand Ubuntu's startup process and how Ubuntu determines which programs to run when it starts.

    Ubuntu uses System V style init scripts. The init scripts are located in a special directory named /etc/init.d. Even though there may be several init scripts present in /etc/init.d , not all of them are run at boot time. Ubuntu organizes which scripts to run for different circumstances into runlevels; most Linux systems have seven runlevels, ranging from 0 to 6.

    A some of these runlevels are set aside for special states in a Linux system:
    Runlevel 0 Halts the system.
    Runlevel 1 Sets up single-user mode.
    Runlevels 2-5 Set up different multi user modes. Although, typically, only one or two of these are used by a distribution.
    Runlevel 6 Reboots the system.

    Each runlevel has a directory that stores symlinks to certain init scripts in /etc/init.d, which are started when that runlevel is selected and stopped when it is exited. Ubuntu puts these symlinks under /etc/rc.d for example, all runlevel 2 scripts are located in /etc/rc2.d/.

    If you look in one of these runlevel directories, you'll notice that many of the symlinks to scripts in /etc/init.d have odd names that begin with an S, K, or D; then a number; and finally the name of the script. Ubuntu defaults to runlevel 2, so here is a partial sample of my /etc/rc2.d directory:

    lrwxrwxrwx 1 root root 19 2009-05-13 09:58 S01policykit -> ../init.d/policykit
    lrwxrwxrwx 1 root root 15 2009-05-13 09:58 S10acpid -> ../init.d/acpid
    lrwxrwxrwx 1 root root 14 2009-05-13 09:58 S10apmd -> ../init.d/apmd
    lrwxrwxrwx 1 root root 18 2009-05-13 09:58 S99ondemand -> ../init.d/ondemand
    lrwxrwxrwx 1 root root 18 2009-05-13 09:58 S99rc.local -> ../init.d/rc.local
    lrwxrwxrwx 1 root root 19 2009-05-13 09:58 S99rmnologin -> ../init.d/rmnologin
    lrwxrwxrwx 1 root root 24 2009-05-13 09:58 S99stop-readahead -> ../init.d/stop-readahead

    As you can see, this directory is full of symlinks that point to a script in the init.d directory.
    The letter at the beginning of each filename tells init when to execute this script. If the script begins with an S, then init starts the script when it goes through the runlevel. If the script begins with a K, then init stops (or kills) the script when it changes to a different runlevel. If the script begins with a D, then that script is disabled for the time being, and init ignores it. init runs the scripts in numerical order, so the numbers in each script let you know in which order they are to be run. This is useful to ensure that dependent services start after the service they are dependent on.
    Ubuntu 9.04 uses upstart daemon to manage init scripts. The configuration files for upstart are located in /etc/event.d/ . ( On earlier systems, the start up was managed from /etc/inittab. You will not find this config file in new ubuntu releases.). When ubuntu boots up the default runlevel is determined by a small script in /etc/event.d/rc-default.
    Next, upstart loads any system scripts from a special system runlevel directory at /etc/rcS.d. These scripts load daemons and services that are vital to the boot process. Lastly, upstart runs any startup scripts for the default runlevel in alphabetical order. Scripts in /etc/rcS.d are run in runlevels 1 through 5, so you should generally leave them alone unless you know what you are doing. If you accidentally disable a crucial service, you may have to resort to a rescue disc to undo the mistake.

    Change the Runlevel

    You can change the runlevel yourself on the command line with the init command. To switch to single-user mode from the command line, type:
    $ sudo init 1

    If you're running X11 when you issue this command, beware, since it will kill X and your desktop environment! This command runs all of the shutdown scripts for your current runlevel and then any start up scripts for single-user mode. To change back to the default multi-user runlevel for Ubuntu, type:

    $ sudo init 2

    You can also use init to halt or reboot a machine: just change to runlevel 0 and runlevel 6, respectively.

    Manually Start and Stop Services

    You can start and stop scripts manually by running the script with the start or stop argument. For example, to stop the CUPS service from the command line, type:

    $ sudo /etc/init.d/cupsys stop

    To start the service back up, type:
    $ sudo /etc/init.d/cupsys start

    Most scripts also support a restart argument that will run stop, then start for you. Most init scripts are also configured to output the list of arguments they support when you execute them without any options:
    ~$ sudo /etc/init.d/cups
    Usage: /etc/init.d/cups {start|stop|restart|force-reload|status}

    Disable Scripts from Starting

    To disable a script, you must know your default runlevel. On Ubuntu, the default runlevel is usually set to 2, but you may want to double-check your default runlevel before you start disabling services.

    You can find out your current runlevel with

    ~$ runlevel
    N 2

    As you can see, in this example, the default runlevel is in fact 2. Now change to the directory containing all of the scripts for that runlevel (/etc/rc2.d) and find the script you want to disable. To disable a service, just rename its script by changing the S to a D. For example, to disable the cupsys service, type:

    ~$ cd /etc/rc2.d
    /etc/rc2.d$ sudo mv S50cups D50cups

    To enable it again, rename it back by changing the D to an S:
    ~$ cd /etc/rc2.d
    /etc/rc2.d$ sudo mv D50cupsys S50cups

    You'll still need to stop the service as shown earlier if you want to shut it down right away, but renaming it will control whether it's started the next time you reboot (or change runlevels).

    Alternately, you can use the update-rc.d command to manipulate the starting /stopping of init scripts.

    Monday, August 24, 2009

    How to Control Startup Services on ubuntu

    As Ubuntu boots up , if you press Cntrl+alt+F8, you might notice text scrolling by, detailing all of the different things Ubuntu is doing. See the screen shot below.

    Apart from loading the kernel and starting the system, a number of services such as cron , gdm, cups etc are started at this time. If you have installed additional services on your system, such as a web server, they will also be started at boot. Sometimes, you may want to either stop or temporarily disable these services, and Ubuntu provides a number of ways to do this, both graphically and through the command line.
    Services Administration Tool
    The graphical tool to start/stop services is localted at

    You can also start it by typing the following command from a terminal.

    $ sudo services-admin

    Press unlock and enter your password. The screen will change to the one given below.

    To disable a service, just deselect its checkbox and click Close. In Jaunty, this application supports changing only whether a service starts at boot. If you want to manually start, stop, or restart a service at a given point of time during your system usage, you need to refer to the command-line method.

    Sunday, August 23, 2009

    GeexBox : a 20MB wonder

    Today , I was playing with geexbox , a 20MB distro specifically built for converting your PC into a powerful multimedia centre. GeeXBoX is based on Debian, it works very well on any x86 PC. Addional images are available for 64 bit architectures and PowerPC. It recognizes a large number of hardware and supports almost any audio / video or images, as well as we can playback CDs, DVDs etc.

    Here are some screen shots .

    The start-up screen

    There are scripts to remaster the image with your own video/audio embeded with in the cd. I am yet to try them out.

    Saturday, August 22, 2009

    Reset a forgotten root password with a live CD

    If you have forgotten the root password of a system, you can very easily reset it with a live CD
    Any live Linux cd from standard Linux distros such a ubuntu , knoppix etc can be used.

    Boot the system with the live CD
    Open a terminal and use dmesg command to find out the hard disk.
    The ide hard disk are generally named as hda, hdb etc. SATA and SCSI disks are named sda sdb etc. My SATA hard disk is detected as below.

    [ 3.206832] sda: sda1 sda2 sda3 sda4 <>
    [ 3.266679] sd 0:0:0:0: [sda] Attached SCSI disk

    The above hard disk has several partitions. sda2 , sda2 ,sda3 are primary partitions , sda4 is divided into several logical partitions. You have to find out where your root partitions is mounted.
    You can use cfdisk to find out the partitions.
    $sudo cfdisk /dev/sda

    I am getting the following screen .

    You can examine the screen and find out the Linux partitions . If you have multiple installations , this can be tricky. You can quit from cfdisk and return to terminal. Now, try to mount the desired partition into some directory. ( Assuming that you Linux partition is /dev/sda2 , the following commands are described.)

    Aquire root powers on the terminal with ( in the case of ubuntu live cd which I use)

    $sudo su
     # mount /dev/sda2  /mnt/  
    Now, chroot to /mnt
      #  chroot /mnt
    Change the password

    # passwd

    Next unmount the partition and enjoy .

    # umount /mnt

    Friday, August 21, 2009

    Cracking zip passwords with fcrackzip

    Fcrackzip is a small utility that can become a handy tool when you want to look for lost zip password.
    Fcracksip i a available in the ubuntu repository and you can install it as
    $ sudo apt-get install fcrackzip

    To see the available options with fcrackzip , try the following.

    $ fcrackzip --help

    You can look for a password like this.

    $ fcrackzip -c a -p aaaaaa

    The above cimmand will check the encrypted files in for all lowercase 6 character passwords (aaaaaa ... abaaba ... ghfgrg ... zzzzzz).

    fcrackzip supports brute force mode as well as dictionary mode. The man page has some more interesting options you can try.

    Wednesday, August 19, 2009

    Replacing the default screen shot utility on ubuntu with shutter

    Shutter, according to its website is a feature full screen shot program. As a tech blogger experimenting with GNU/Linux and its derivatives, it offers me a number of handy features. In fact, I have replaced it as my default screen shot tool. When I press Print Screen on my keyboard,shutter pops up and does a nice job.


    The shutter website hosts a step by step installation tutorial for graphical installation on Ubuntu. If you are oriented towards command line, follow these steps

    1) Import the GPG key
    $ sudo wget -q -O- | sudo apt-key add -
    2) Add the PPA repository--- to /etc/apt/sources.list
    deb jaunty main

    ( Replace jaunty with your version of ubuntu)

    3) Install shutter
    $ sudo apt-get update
    $ sudo apt-get install shutter


    Shutter offers lot of features for a blogger. Some of them are,
    • take a screen shot of your complete desktop, a rectangular area or capture a website
    • take screen shot directly or with a specified delay time
    • save the screen shots to a specified directory and name them in a convenient way (using special wild-cards)
    • Shutter is fully integrated into the Gnome Desktop (TrayIcon etc.)
    • generate thumbnails directly when you are taking a screenshot and set a size level in %
    • Shutter session collection
      • keep track of all screenshots during session
      • copy screeners to clipboard
      • print screenshots
      • delete screenshots
      • rename your file
    • upload your files directly to Image-Hosters (e.g., retrieve all the needed links and share them with others
    • edit your screenshots directly using the embedded drawing tool

    Making shutter the default screen shot tool on Ubuntu.
    Assuming that you are using Genome desktop on ubuntu, you can set Print Screen and Alt-Print Screen can be
    configured to launch shutter as below.
    a) Open shutter
    b) Select Edit->preferences from the menu
    c) Click on behavior tab . See the screen shot below.

    d) Enable Gnome Key binding by ticking the check boxes.

    Monday, August 17, 2009

    Using multiple window managers with nested Xserver

    I use gnome as my default desktop at home and at office. However, my machines have alternate desktop environment such as kde or xfce installed. I use it to test out features of these environment. The normal way to switch to a different desktop is to log out from the current desktop , select a new session from the gdm login window and login again. However, it is possible to open a new desktop environment in a virtual console using xnest nested xserver.


    $ sudo apt-get install xnest

    Using Xnest to run another window manager.

    Method 1
    Xnest server can be started from a terminal as below

    Xnest :1 -ac &

    See the screen shot below. The :1 above indicates virtual X display numbered 1. You can also try other numbers.

    Now on the terminal , Type the following command.
    export DISPLAY=:1

    The above line exports the variable DISPLAY to :1. Now you can open a terminal in the Xnest window by typing xterm & in the terminal. See the screen shot below.

    Now try to start up a window manager such as icewm by typing icewm inside the xterm.

    I could start icewm and fluxbox and kde like this. However, trying to start gnome-session resulted in some error. I am yet to find out the reason .

    Method 2
    This method uses gdmflexiserver . gdmflexiserver is a part of gdm and it is used to run gdm session on demand on a virtual terminal.

    You can start it to give a gdm login prompt as below.

    $ gdmflexiserver -n

    You will get a new virtual X with a gdm login screen. See the picture below.

    You can log in as a different user using a different session from the above screen. ( All the screen shots were taken on ubuntu 8.10)

    Friday, August 14, 2009

    Importing a remote desktop session via ssh tunnel

    At home I have, 2 machines, one running Ubuntu 9.04 (Jaunty) and the other running Ubuntu 8.04 (Hardy). The Hardy machine is used by my family members and I use Jaunty for my experiments. Some times, I would like to test some thing on Hardy also. But most of the times that machine is not free. I use ssh to login to the hardy box and use an ssh tunnel to export the GUI session back to my Jaunty box.

    The steps I took are detailed below.

    On Hardy box

    1) Install open ssh server

    $sudo apt-get install openssh-server

    On Jaunty Box

    2) I switch to a text terminal by pressing Control+ALT+ F2. (any thing from F1 to F6 will work)

    3) Login to the text terminal

    4) Start a new session on Virtual Terminal 8 and launch xterm on it.

    $ xinit /usr/bin/xterm -- :1

    ( :1 above represents the virtual graphical display , you can also use :2 )

    5) A gray screen with xterm will appear on virtual terminal 8. If it is not appearing you can switch to it by

    $ chvt 8

    Or by pressing Control+Alt+f8

    6) Now ssh to the Hardy box with tunneling.

    $ ssh -Y fermi@

    Give your credentials and login (The IP address above is that of my Hardy box, you can replace it with your user name and IP). You are now logged to Hardy. The GUI of any program launched on Hardy ( in this terminal) will be tunneled back to Jaunty via ssh.

    7) Start a gnome session on Hardy by typing the following command in the xterm terminal.

    $ gnome-session

    You can start other desktop sessions like kde or xfce , if they are installed.

    Thursday, August 13, 2009

    Tweaking dhcp client configuration to change the default DNS servers to Open DNS

    The DNS servers of my ISP is always behaving erratically. The DNS look up times are abysmally large and some times I get an address not found error while browsing. On ubuntu/debian systems the DNS servers are specified in /etc/resolv.conf. I tried to edit /etc/resolv.conf and put open dns servers as default DNS servers. But, my ISP supplies their DNS server address along with IP address for the system via DHCP. Every time my system renews its DHCP lease. my /etc/resolv.conf is also rewritten with their DNS address.

    My /etc/resolv.conf ( supplied by ISP) looks like this.

    $ cat /etc/resolv.conf

    There is a trick I used to make Open DNS servers as my default DNS server.

    Edit /etc/dhcp3/dhclient.conf and look for the line.
    #prepend domain-name-servers;
    Add the following line immediately below the above line.

    prepend domain-name-servers;
    prepend domain-name-servers;

    You can also put any other DNS servers.

    Now renew the lease with

    $ sudo dhclient eth0

    The new /etc/resolve.conf looks like this.
    $ cat /etc/resolv.conf

    DNS look up is made from open dns.

    Tuesday, August 11, 2009

    How to install LTSP on ubuntu 9.04

    LTSP was available as an install option in Ubuntu 8.04 and 8.10 from the alternate install CD . However I am unable to find it on the Jaunty CD. So, here is a quick how to on installing LTSP on ubuntu 9.04.

    1) Install Ubuntu 9.04 desktop
    You can follow the default documentation on Ubuntu site.

    2) Set up a static IP on the system
    You can refer to this post for setting up static IP on Jaunty.

    3) Install dhcp3 server

    $ sudo apt-get install dhcp3-server

    You may also refer to this post for some more details on dhcp3 installation on Ubuntu 9.04.

    4) Install open ssh server

    $ sudo apt-get install open-sshserver

    Ltsp uses ssh to tunnel X to the client machines.

    5) Install ltsp

    $ sudo apt-get install ltsp-server-standalone

    This will download all the package needed for building LTSP.

    6) Edit /etc/ltsp/dhcpd.conf to suit your IP requirement

    The default dhcp3-server configuration file is in /etc/dhcp3/dhcpd.conf. However when ltsp was installed it created a new config file for dhcp3 under /etc/ltsp/dhcp3.conf. You have to edit this dhcp3.conf to suit your IP requirements.

    My dhcpd.conf looks like this. You can use this as a starting point.

     # Default LTSP dhcpd.conf config file.



    subnet netmask {


    option domain-name "";

    option domain-name-servers;

    option broadcast-address;

    option routers;

    # next-server;

    # get-lease-hostnames true;

    option subnet-mask;

    option root-path "/opt/ltsp/i386";

    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {

    filename "/ltsp/i386/pxelinux.0";

    } else {

    filename "/ltsp/i386/nbi.img";



    7) Run LTSP build client

    $ sudo ltsp-build-client

    This command will build the ltsp environment under /opt/ltsp and build the squashfs image for clients.

    8) Enable pxe boot on a client machine and test the set-up.

    Trouble shooting

    1) If your client boots up and says "You are not authorised to connect to server" , run the following.
    $sudo ltsp-update-sshkeys
    $sudo ltsp-update-image

    2) If you change the IP address of the server, run the same commands again, ie

    $sudo ltsp-update-sshkeys
    $sudo ltsp-update-image

    Monday, August 10, 2009

    Five gui hex editors for ubuntu

    This evening, I was looking at some microcontroller files and I needed a hex editor to tweak the machine code. That led me to search for a good hex editor for my ubuntu desktop. I downloaded several programs (GUI as well as console) and poked around a bit with each. Here are five gui hex editors you can use on ubuntu 9.04.

    1) Ghex

    Ghex is hex editor for GNOME. GHex allows the user to load data from any file, view and edit it in either hex or ascii.
    On ubuntu 9.04 , ghex is available in universe repository.

    $ sudo apt-get install ghex

    2) Khexedit

    I could not locate the current home page of khexedit on internet. It is good editor based on kde 3.5. Unfortunaltley , khexedit is missing in the Jaunty repository. I downloaded khexedit form the hardy repository, and nstalled the package with

    $ sudo dpkg -i khexedit_3.5.9-0ubuntu3_i386.deb

    The screen shot looks like below.

    3) Okteta

    Okteta is a KDE utility. It is included in the new KDE 4.3 also. The data is displayed in two variants: as the numeric values of the bytes and as the characters assigned to the values. Values and characters can be shown either in two columns (the traditional display in hex editors) or in rows with the value on top of the character. Editing can be done both for the values and for the characters. Besides the usual editing capabilities Okteta also brings a small set of tools, like a table listing decodings into common simple data types, a table listing all possible bytes with its' character and value equivalents, a info view with a statistic, a checksum calculator and a filter tool. All modifications to the data loaded can be endlessly undone or redone.

    On ubuntu 9.04 you can install okteta with

    $ sudo apt-get install okteta

    Octeta looks like this screen shot.

    4 ) Wxhexeditor


    wxHexEditor is another Hex Editor useful for editing large files. Debian/Ubuntu package is not available now. However, you can download it in source or get a binary from here. It is still in alpha but looks very promising.

    5 lfhex


    lfhex is an application for viewing and editing files in hex, octal, binary, or ascii text. The main strength of lfhex is it's ability to work with files much larger than system memory.
    The interface is not very impressive. It can be installed with

    $ sudo apt-get install lfhex

    See the screen shot below.

    Among the five editors mentioned above, ghex is my favorite as it is stable and userfriendly.

    Sunday, August 9, 2009

    Howto setup Second IP address or Virtual IP address to your Networkcard in ubuntu

    If you are a Network Administrator some time you need to assign more than ONE ip address (second ipaddress) to your network card of Ubuntu machine. For this you need to edit the /etc/network/interfaces file by adding the following lines .

    See this how to from Shibu Varkala for details.

    Exploring Ubuntu Recovery Mode

    Today, I did a fresh installation of Ubuntu 9.04 inside virtual box. My original idea was to play with sudoers and sudo command. I edited /etc/sudoers and logged out. Next time I tried to sudo , I go some parse error in /etc/sudoers. I was stuck . I needed sudo for modifying the file. But sudo was preventing me because of the error.

    Then, I remembered about the recovery mode. Rebooted the machine and I pressed escape to get the standard grub screen as shown below.

    Selecting recovery mode showed the following screens. ( The second figure below shows the remaining part of the recovery screen which is hidden from the first screen.)

    I selected drop to a root shell. It allowed me to enter root account with out a password. I fixed my /etc/sudoers and my problem was gone.

    Later I rebooted again and re-entered the recovery mode again to find out what capabilities it offers.

    The recovery screen offers you the following menu entries on ubuntu 9.04 .

    a) Try to make free space - this is useful if your machine is stuck for the want of free disk space.
    b) Dpkg - If you select this option you can repair broken packages. Very useful ,if the system is stuck after a package installation.
    c) fsck - if the system is stuck with file system error you can try this option.
    d) grub - You can update the grub boot loader from this option.
    e) netroot - Your TCP/IP network settings will be enabled and system will drop to a root shell.
    This option is useful if you are trouble shooting network related issues.
    f) root- Plain old root shell . Suitable for editing config files.
    g) xfix - This option will try to reconfigure your X window system