[HOWTO] Install Linux Kernel 3.0 in Ubuntu 11.04 Natty Narwhal

Linux Kernel 3.0 RC 1 was recently released. Although it does not have real changes to anything, but is just a renaming of 2.6.40, however, you may want to install it for testing and using it if it works good for you in your Ubuntu Natty installation. It has bug fixes and additional drivers so it may solve problems. However, it may also introduce new problems, so be careful not to remove the other kernel (2.6.38) after installing it. This tutorial also contains instructions to remove it safely, so read along. Ubuntu 11.10 Oneiric Ocelot will be released with kernel 3.0.

As of writing this, only amd64 (64 bit version) of the kernel is available in Kernel PPA, so if you are using 32-bit, it will not work for you. However, if you find i386 builds in the kernel ppa, you can install it. (UPDATE: Now both 32-bit and 64-bit versions are available)

First of all, download the debs from Kernel PPA. Then install in this order:

Once installation is done, reboot and Ubuntu should boot into 3.0 by default. If everything works right, you may want to keep it, however, if it does not, don’t worry, just reboot and select one of the previous versions and boot into it. Then open up synaptic, search for linux-headers-3 and linux-image-3 and remove the 3.0 versions.

If you are reading this after other versions are released, you may want to check out kernel ppa.

[HOWTO] Install SBaGen in Fedora

I am running Fedora 14 32 bit (and now Fedora 15 64 bit for which I have updated the article) and I wanted to install SBaGen for some binaural entertainment. So, here is how I did it:


mkdir sbagen
cd sbagen
wget http://uazu.net/sbagen/sbagen-1.4.4.tgz
tar xzvf sbagen-1.4.4.tgz
cd sbagen-1.4.4

Install dependencies

sudo yum install libmad-devel libvorbis-devel gcc

Run Build Script

For 32 bit:


For 64 bit:

wget "https://launchpadlibrarian.net/35151187/libvorbisidec_1.0.2+svn16259.orig.tar.gz"
tar xzvf "libvorbisidec_1.0.2+svn16259.orig.tar.gz"
cd "libvorbisidec-1.0.2+svn16259"
sudo make install
sudo ln -s /usr/local/lib/libvorbisidec.so.1 /usr/lib64/libvorbisidec.so.1
cd ..
cp /usr/lib64/libvorbisidec.so.1 libs/linux-libvorbisidec.a
cp /usr/lib64/libmad.so libs/linux-libmad.a

That should build a sbagen executable in the same directory. Run the following to verify:


It should output something like this:

SBaGen – Sequenced Binaural Beat Generator, version 1.4.4
Copyright (c) 1999-2007 Jim Peters, http://uazu.net/, all rights
reserved, released under the GNU GPL v2. See file COPYING.

Usage: sbagen [options] seq-file …
sbagen [options] -i tone-specs …
sbagen [options] -p pre-programmed-sequence-specs …

For full usage help, type ‘sbagen -h’. For latest version see
http://uazu.net/sbagen/ or http://sbagen.sf.net/

Now, copy it to /usr/bin/ and thats all.

sudo cp sbagen /usr/bin/

Now, you must be able to run it. Try running an example:

sbagen examples/basics/prog-chakras-1.sbg

If you get something along the lines of:

Can’t open /dev/dsp, errno X

You will need to prefix the command by padsp like this:

padsp sbagen examples/basics/prog-chakras-1.sbg

Hope this helps.

[HOWTO] Install Firefox 4 in Ubuntu 10.04 Lucid Lynx and 10.10 Maverick Meerkat

Firefox 4 has been released recently and it is not available via update manager in Ubuntu 10.04 Lucid Lynx and 10.10 Maverick Meerkat. The Ubuntu Mozilla Daily Build PPA provides it but it always the latest daily build and not the stable version.

For stable version, you can use Firefox Stable PPA. To install the PPA in Lucid or Maverick, just launch Synaptic (System>Administration>Synaptic Package Manager) and then go to Settings>Repositories>Other Software. Now click Add and paste in the following:


Close the Repositories window and then click reload. When it is done, search for firefox-4.0-gnome-support and mark it for installation. It should mark other required packages. Apply and wait for installation to finish.

[SOLVED] Selenium server not working in Netbeans 6.9.1

I am using Fedora Core 14 and have installed Selenium Module for PHP. I was not able to run PHPUnit tests on Yii Framework. I tried running Selenium server 1.0.1 and upgrade to 1.0.3 solved the problem.

I downloaded the Selenium Remote Control from here and extract the file selenium-server.jar, renamed it to selenium-server-1.0.1.jar and placed it in /home/myusername/.netbeans/6.9/modules/ext/selenium overwriting the old jar. Then I restarted Netbeans. Now, testing works.

Hope this helps.

[HOWTO] Remount /cdrom as Read-Write in a Live Unetbootin Setup

If you have used Unetbootin to setup a Live Ubuntu Environment, you will find that the partition containing the Unetbootin files will be mounted on /cdrom as read-only, which means, even if you launch nautilus with gksu or sudo, you will not be able to make changes to the file-system. There is however, an easy workaround which involves remounting the filesystem with a single command. Open up the terminal and type in the following:

sudo mount /cdrom  -o rw,remount

Now, you should be able to write into the filesystem.

[HOWTO] Run apache server with www directory in a different server

This is an experiment in which I wanted to see if it is possible to run apache on one server and have www directory in a different server (physical or virtual). I don’t know the possible benefits of such a system or a scenario where this could be helpful, neither am I aware of different ways to achieve the same. But I tried it and am posting the results anyways. 😀

The Problem

I am assuming a hypothetical problem where a user wants to run apache server in one machine and have the www directory in a different system. Let’s call the machine with apache2 installed as Web Server (WS) and for the system with www directory, lets use the name File Server (FS).

The Plan

The plan is to mount the www directory of FS to a directory of WS with sshfs and configure apache in WS to use that sshfs directory.

Working Environment

I am using my Debian Testing system as FS and Ubuntu 10.10 Maverick Meerkat inside VirtualBox virtual machine (using Bridged connection) as WS which has apache installed. I have openssh server installed in FS and openssh client and sshfs installed in WS.

Plan Execution

Apache Configuration
First, lets login to WS and configure apache to use a directory in normal user’s home directory (/home/ws_username/www) by editing /etc/apache2/sites/available/default. The DocumentRoot is set to /home/ws_username/www and a Directory is set to /home/ws_username/www/ (no virtual hosts, however, using virtual hosts should not be much different either).
Stop apache server for now:

sudo service apache2 stop

Testing SSH connection from WS to FS
Now, connect from WS to FS using:

ssh fs_username@fs_ip_or_domain_name

and verify connection is OK. Add to known hosts (if connecting for the first time). Then type


to disconnect.
Setting up SSH connection without password
If not already created, create a ssh key pair using the command in WS:


That should ask you where to store the rsa public key (it is stored by default in /home/ws_username/.ssh/id_rsa/ as /home/ws_username/.ssh/id_rsa/id_rsa.pub). Use a blank password. If you use a password, you may have to use ssh-agent for authentication later (not covered in this article). Now, transfer the pub key to FS using scp.

scp ~/.ssh/id_rsa/id_rsa.pub fs_username@fs_ip_or_domain_name:

Then, ssh to FS:

ssh fs_username@fs_ip_or_domain_name

Now, add the rsa keys copied from WS earlier to authorized_keys file in FS:

cat id_rsa.pub >>~/.ssh/authroized_keys
rm id_rsa.pub

Exit to disconnect and drop to WS shell.
Testing SSH connection from WS to FS without password
If you followed the instructions correctly, you will be able to connect to FS from WS without password when you use SSH.

ssh fs_username@fs_ip_or_domain_name

Exit to disconnect:


Manually mount the www directory in FS to WS using sshfs
Now, test if sshfs is able to mount the directory from FS to WS. Let us assume the www directory is in /home/fs_username/webprojects and is properly readable/writable (as required) by fs_username.
First, allow the user to mount by adding the ws_username to fuse group by running the following command:

sudo gpasswd -a ws_username fuse

Mount the directory to /home/ws_username/www using sshfs:

sshfs -o idmap=ws_username fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects  /home/ws_user/www

Confirm successful mounting by listing the contents:

ls /home/ws_username/www

Unmount when done testing:

fusermount -u /home/ws_username/www

Setup /etc/fstab to be able to mount and unmount using mount and unmount instead
Open up /etc/fstab and add the following line:

sshfs#fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects /home/ws_username/www fuse fsname=sshfs#fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects,users,allow_other,uid=1000,gid=104,comment=sshfs,exec,reconnect,transform_symlinks,BatchMode=yes,noauto 0 0

Don’t use uid and gid values as they appear above. Instead, get those values by running the following command in terminal:


Make sure to use the uid and gid (of fuse group) from the output of the above command. Save the file.
Then open up /etc/fuse.conf and add or uncomment the line:


Try mounting and unmounting using mount and unmount

mount /home/ws_username/www
ls /home/ws_username/www
umount /home/ws_username/www

Setup auto-mount on connection (ifup) and auto-unmount on disconnect (ifdown)
Create a file /etc/network/if-up.d/mountsshfs with the following contents:


## http://ubuntuforums.org/showthread.php?t=430312
## The script will attempt to mount any fstab entry with an option
## "...,comment=$SELECTED_STRING,..."
## Use this to select specific sshfs mounts rather than all of them.

# Not for loopback
[ "$IFACE" != "lo" ] || exit 0

## define a number of useful functions

## returns true if input contains nothing but the digits 0-9, false otherwise
## so realy, more like isa_positive_integer 
isa_number () {
    ! echo $1 | egrep -q '[^0-9]'
    return $?

## returns true if the given uid or username is that of the current user
am_i () {
	[ "$1" = "`id -u`" ] || [ "$1" = "`id -un`" ]

## takes a username or uid and finds it in /etc/passwd
## echoes the name and returns true on success
## echoes nothing and returns false on failure 
user_from_uid () {
    if isa_number "$1"
		# look for the corresponding name in /etc/passwd
    	local IFS=":"
    	while read name x uid the_rest
        	if [ "$1" = "$uid" ]
				echo "$name"
				return 0
    	done </etc/passwd
    	# look for the username in /etc/passwd
    	if grep -q "^${1}:" /etc/passwd
    		echo "$1"
    		return 0
    # if nothing was found, return false
   	return 1

## Parses a string of comma-separated fstab options and finds out the 
## username/uid assigned within them. 
## echoes the found username/uid and returns true if found
## echoes "root" and returns false if none found
uid_from_fs_opts () {
	local uid=`echo $1 | egrep -o 'uid=[^,]+'`
	if [ -z "$uid" ]; then
		# no uid was specified, so default is root
		echo "root"
		return 1
		# delete the "uid=" at the beginning
		uid_length=`expr length $uid - 3`
		uid=`expr substr $uid 5 $uid_length`
		echo $uid
		return 0

# unmount all shares first
sh "/etc/network/if-down.d/umountsshfs"

while read fs mp type opts dump pass extra
    # check validity of line
    if [ -z "$pass" -o -n "$extra" -o "`expr substr ${fs}x 1 1`" = "#" ]; 
        # line is invalid or a comment, so skip it
    # check if the line is a selected line
    elif echo $opts | grep -q "comment=$SELECTED_STRING"; then
    	# get the uid of the mount
        mp_uid=`uid_from_fs_opts $opts`
        if am_i "$mp_uid"; then
			# current user owns the mount, so mount it normally
			{ sh -c "mount $mp" && 
				echo "$mp mounted as current user (`id -un`)" || 
				echo "$mp failed to mount as current user (`id -un`)"; 
			} &
		elif am_i root; then
			# running as root, so sudo mount as user
			if isa_number "$mp_uid"; then
				# sudo wants a "#" sign icon front of a numeric uid
			{ sudo -u "$mp_uid" sh -c "mount $mp" && 
				echo "$mp mounted as $mp_uid" || 
				echo "$mp failed to mount as $mp_uid"; 
			} &
			# otherwise, don't try to mount another user's mount point
			echo "Not attempting to mount $mp as other user $mp_uid"
    # if not an sshfs line, do nothing
done </etc/fstab


Create another file /etc/network/if-down.d/umountsshfs with the following contents:


# Not for loopback!
[ "$IFACE" != "lo" ] || exit 0

# comment this for testing
exec 1>/dev/null # squelch output for non-interactive

# umount all sshfs mounts
mounted=`grep 'fuse.sshfs\|sshfs#' /etc/mtab | awk '{ print $2 }'`
[ -n "$mounted" ] && { for mount in $mounted; do umount -l $mount; done; }

Make both files executable and owned by root:

sudo chmod 755 /etc/network/if-up.d/mountsshfs /etc/network/if-down.d/umountsshfs
sudo chown root:root /etc/network/if-up.d/mountsshfs /etc/network/if-down.d/umountsshfs

Test the working of scripts
Enter the commands (assuming the ethernet interface as eth0):

sudo ifdown eth0   #disconnect
sudo ifup eth0   #connect

Test if the directory is mounted:

ls /home/ws_user/www #should list files


sudo ifdown eth0

Test if the directory is unmounted:

ls /home/ws_user/www #should not list files

Connect back:

sudo ifup eth0   #connect

You can also reboot the system to test if the directory properly mounts at startup.

Start Apache and Test

sudo service apache2 restart

Test using a web browser.



[HOWTO] Setup a Minimal Ubuntu LAMP server (with ssh server)

In this article, I will describe how I went about to install the bare minimum LAMP server using Ubuntu Minimal installation iso. I downloaded Maverick Meerkat version of Minimal CD image from the Minimal CD Image Download Page. You can use the server ISO but you may end up with unwanted packages and you will need to download the whole ~700 MB ISO to start, while Minimal CD is just ~13MB. Also, since the Minimal CD downloads the latest packages from the repos during installation, you need not update immediately further saving data volume.

I am installing inside VirtualBox 4.0 Beta. However, these instructions should apply to other Virtualization solutions or even a physical machine.

Boot into the computer with the CD Image (either burn it to business card CD-ROM or normal CD-ROM if using Physical Machine otherwise just mount inside VirtualBox) and follow the on-screen instructions and select appropriate settings that apply to you. At the last stages of the installation, you will be asked to select packages, select none. It will complete installing the basic packages and install Grub and reboot.

After reboot, you will be able to login. After logging in, enter the following command:

sudo apt-get install mysql-server phpmyadmin ssh

The above command should install the following components:

At the end of the installation, just select appropriate settings and setup passwords.

Now, when you launch a browser in another machine, you can open http://IP.OF.THE.MACHINE and you will see that system is ready, if everything went right. The installed size is less than 1GB (excluding swap).

Hope this helps.

[HOWTO] Bring back “Network”, “Services”, “Time and Date” and “Users and Groups” in Gnome Menu

If you have installed your system via netinstall or by selecting packages one by one, or if you somehow removed some gnome packages, you may be missing some menu items. I noticed that I did not have some entries in System>Administration menu, namely, “Network”, “Services”, “Time and Date” and “Users and Groups”. I tried to search for them in Synaptic and Apt-file but failed to locate the exact package. So, I did some hit and trial and found the package was “gnome-system-tools”. I just installed it via synaptic and the menu entries were back.

[HOWTO] Properly install VirtualBox 4 beta in Ubuntu/Debian/Linux Mint (and other Debian/Ubuntu derivatives)

I downloaded deb of VirtualBox beta 1 from the beta packages page of Oracle website and installed it. However, while launching Virtual Machines created with Oracle VirtualBox 3.x (closed source version), I got the following error:

Failed to open a session for the virtual machine [machine name].
A virtual device is configured in the VM settings but the device implementation is missing.
A possible reason for this error is a missing extension pack. Note that as of VirtualBox 4.0, certain features (for example USB 2.0 support and remote desktop) are only available from an ‘extension pack’ which must be downloaded and installed separately (VERR_PDM_DEVICE_NOT_FOUND).

Result Code:
NS_ERROR_FAILURE (0x80004005)
IConsole {515e8e8d-f932-4d8e-9f32-79a52aead882}

It was clear that it requires an extension pack. I went back to the download page and found an extension pack named “Oracle_VM_VirtualBox_Extension_Pack-4.0.0_BETA1-68572.vbox-extpack” (newer versions may be available now so name may be different) and downloaded it. I installed it by double clicking it. It opens with VirtualBox by default (if it doesn’t, open with and select VirtualBox). The following error popped up:

Failed to install the Extension Pack /path/Oracle_VM_VirtualBox_Extension_Pack-4.0.0_BETA1-68572.vbox-extpack.
Failed to locate load the main module (‘/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.x86/VBoxPuelMain.so’): VERR_FILE_NOT_FOUND.

Result Code:
NS_ERROR_FAILURE (0x80004005)
IExtPackManager {8104df65-74d6-4e33-b374-50aa062b4afd}

When I tried to launch a Virtual Machine, I got the previous error. However, when I tried to reinstall the Extension, I got the following error:

Extension pack ‘Oracle VM VirtualBox Extension Pack’ is already installed. In case of a reinstallation, please uninstall it first.

I learned from WebUpd8 that libstdc++5 was required for it. So, I just installed it by typing the following in terminal:

 sudo apt-get install libstdc++5

Then, after restarting VirtualBox, I was able to launch my Virtual Machines again.

[HOWTO] Enable sound in Mac OS X Snow Leopard 10.5.x or 10.6.x running in VirtualBox

I have recently installed Mac OS X Snow Leopard 10.6.3 with iATKOS 3 v2 disk as guest OS in VirtualBox 3.2.12 with Debian host. After fixing the video resolution issue, I noticed that there was no sound. However, VirtualBox Forum user OmegaX has written a sound driver for Mac OS X 10.5.x and 10.6.x. It can be downloaded from here. Since I don’t have Xcode installed, and since I did not want to go through the hassle of installing the kext manually, I downloaded the binary installer, unpacked it by double clicking on it and installed it. It seems to take forever, but it installs successfully. The sound is working fine after a reboot.