Sunday, January 6, 2008

Fun with Ubuntu

A distribution of Linux I recently tried is Ubuntu. "Ubuntu" is an ancient African word, meaning "humanity to others". The operating system is extremely slick, cool, and user-friendly. Actually I like it! It is based off of Debian GNU/Linux. You can download its latest version (7.10 Gutsy Gibbon released on 18 October 2007) from the official website here. You can also learn about its desktop and server editions. Like most Linux distributions, it is free and open source.

There are also a number of interesting derivatives of Ubuntu such as:
Ubuntu Studio - Designed for multimedia editing and creation.
Kubuntu - Ubuntu with the K Desktop Environment (KDE).
Edubuntu - Ubuntu for Education.
Xubuntu - Ubuntu with the XFCE desktop environment.
Gobuntu - A flavour of Ubuntu that strives to be completely devoid of software, drivers or firmware with restrictive licenses.

Dell also offers some of its consumer systems with Ubuntu pre-installed!

My adventure with Ubuntu began with trying to evaluate a certain piece of software that required installing QEmu on Linux. In this particular case, choosing Ubuntu as the Linux flavor meant "life is easier" (i.e. I would not have to deal with missing dependencies or packages).

Installing Ubuntu

So I downloaded the ISO for the latest version (Ubuntu 7.10), for a 32-bit machine (i386 or x86), from the official website and burnt it to a CD. Note that sometimes when you burn the CD at 40x speed, the final disk acts funny or gets corrupt! A burn speed of 10x seems to give no problems. In my case, I got the server edition of Ubuntu which unfortunately does not come with the nice GUI like the desktop edition. I learned the hard way, and below I will describe how to install the GUI for the server edition.

Simply follow the installation instructions and soon you will have Ubuntu installed on your system. Note that Ubuntu does not have a "root" user nor does it prompt for a "root password" during installation. This is because, for security reasons, it does not want anyone to login as "root". In order to perform any tasks or actions via command line that require administrator privileges, simply use "sudo ". This prompts for a password for the currently logged-on user. In case of GUI programs, a pop-up box asks to enter the password for the currently logged-on user (much like UAC on Window's Vista).

Note that "sudo" will only escalate privileges of the current command and won't work in case of re-directions. Example: Say you want to write to a system file that requires administrator privileges and you type the following command:

sudo echo 1 > /proc/sys/net/ipv4/tcp_sack

You would still get "Permission denied". This is because "sudo" only performed on "echo 1" but not on "writing to file". There are two ways of tackling this:

(1) Escalate privileges of entire shell, execute your command withing the escalated shell, and then exit escalated shell. This is done as shown:

sudo bash
echo 1 > /proc/sys/net/ipv4/tcp_sack

(2) A second method is by using the following command:

sudo bash 'echo 1 > /proc/sys/net/ipv4/tcp_sack'

Good ole GUI, where are you?

Well, after installing the server version of Ubuntu, I noticed that I wasn't presented with a nice GUI to play around, instead was faced with the command prompt. Nothing against command lines, but I like my GUIs :)

So I learned that typing the command "startx" will start the X server and associated GUI environment. But on executing the command, I am confronted with the following errors:

xauth: creating new authority file /root/.serverauth.38.66
xauth: creating new authority file /root/Xauthority
xauth: creating new authority file /root/Xauthority

X: cannot stat /etc/X11/X (no such file or directory), aborting
giving up
xinit: Connection refused (errno111): unable to connect the x server
xinit: No such process (errno 3): Server Error.

Aah! so I am missing X server and a GUI environment. I needed to install them first. For that, I used the following commands:

sudo apt-get install kde
sudo apt-get install xorg

This installs the KDE GUI environment and X server.

Now type "startx" and you will be presented with the KDE desktop. Do not type "sudo startx" which will cause all your applications to run with administrator privileges, and hence reducing security. On logging out, you will once again be presented with the command shell.

To rather be presented with the GUI (all the way), without having to encounter the command shell each time and typing "startx", simply install one of the GUI desktops all together, instead of the above two packages (kde and xorg). For installing one of the GUI desktops, type any one of the following commands:

To install the default GNOME desktop:
sudo apt-get install ubuntu-desktop

To install the KDE desktop:
sudo apt-get install kubuntu-desktop

After install, reboot your machine and you will be presented with a nice GUI based desktop :)

Some things I learned

In the process of trying to figure out these things, I learned some new things, which I would like to share here. Most Linux distributions have the file "/etc/inittab" that defines the "runlevel" into which the kernel boots up. Typically a runlevel of 2 means you will be presented with a command prompt, and a runlevel of 5 means you will be presented with a GUI. Example: for runlevel 5, the entry in "/etc/inittab" would be as such:


The following command gives the current runlevel you are in:

who -r

The following command will change your runlevel to 2 by shutting down unnecessary process's and starting up all runlevel 2 processes:

telinit 2

Each defined runlevel will have an "/etc/rcX.d/" directory where "X" is the runlevel number.
The contents of the "rcX.d" directory determines what happens at that runlevel. For Ubuntu, the default runlevel is 2. Also, the runlevels 2 through 5 on Ubuntu are all the same. There is no distinction between them, i.e. the contents of /etc/rc2.d/, /etc/rc3.d/, /etc/rc4.d/, /etc/rc5.d/ directories are all the same. This presents you with the default command line shell when you boot up, if you hadn't installed any of the GUI desktops.

Note that in Ubuntu, "init" has been replaced by "upstart". So, if you wish to change you runlevel, "upstart" still looks for the "inittab" file for a user set runlevel. Just create the "/etc/inittab" file and put the following line in it to boot to runlevel 5:


And then you have to add some new content to the directory "
/etc/rc5.d/" in order to start the X server and GUI environment by default on boot up (instead of the command line shell). This I am not sure how to do yet!

Accessing a Window's share from Ubuntu

In order to access a Window's shared folder in Ubuntu, over the network, you need to install "smbfs". Select System > Administration > Synaptic Package Manager and search for "samba server". Then select "smbfs" for install. This will install the and insert the "smbfs" kernel module (.ko - kernel object file) into the running kernel. This facilitates mounting of remote SMB share (such as the Window's share) on Linux. You can find if the kernel module has been properly inserted by executing the following command:

lsmod | grep smbfs

If you do not see it inserted, then you can manually insert the associated kernel object (.ko file) by issuing the following command:

modprobe smbfs

Also make sure that the "smb server" is up and running. In order to check this, type the following command:

netstat -antupo

Check to see if the "smb server" is listening on ports 139 and 445. If not, you can start it by issuing the following commands:

cd /etc/init.d/
./smb start

Now say the IP address to your Window's machine over the network is "". Then type the following command:

smbclient -L

When prompted for "Password" simply hit "Return". This will list all shared folders on the Window's machine that do not require a password for read access. Say one of these shared folders is called "Documents". Then type the following command:

sudo mkdir /mnt/share
sudo chmod 755 /mnt/share
sudo mount // /mnt/share

The first two commands will create the directory "/mnt/share/" and give appropriate permissions. The third command will mount the Window's share onto "/mnt/share/". If prompted for "Password", simply hit "Return".

In order to un-mount the share, type the following command:

sudo umount /mnt/share

Useful info and links

During my learning experience with Ubuntu, I also stumbled upon a number of useful resources, that I would like to share here:

Loads of help at Ubuntu Forums.

Documentation for Latest Version of Ubuntu.

Useful documentation for Ubuntu, browse by title.

Switching to Ubuntu from Windows.

Switching to Ubuntu from MacOS.

Ubuntu equivalents to Windows applications.

Software Equivalents in Ubuntu.

How-To: Setting up QEmu on Ubuntu with TUN/TAP and NAT.

How-To: Install and run Windows 2000 under QEmu on Ubuntu 5.10.

How-To: Install and run Windows XP under QEmu on Ubuntu.

How-To: Install and run any release of Ubuntu under QEmu on Ubuntu.

How-To: Install and run Ubuntu under QEmu or VMware on Windows.

How-To: Install and run VMWare Server (or Workstation) on Ubuntu.

Wiki page: About QEmu, and installing it on Slackware Linux

Installing Wine on Ubuntu.

Installing Internet Explorer on Ubuntu.

Seamless Virtualization with Ubuntu.

Kernel Virtual Machine on Ubuntu.

Hope this information has been useful.
Happy Ubuntu-ing... :)

Digg This | Slashdot This | Add to

No comments: