Sunday 8 June 2008

Closing applications that have hung - part 2

In my previous post, there were some things I missed out, which I'll now fill you in on. First of all, if something has hung, it can be a pain to try and launch a terminal just to close something down, but you don't need to. Just press Alt+F2 in Ubuntu to get the Run dialog and enter xkill there.

But what about if the entire screen has hung and it's too slow to do anything? Well, there's several options here. You can press Ctrl+Alt+Backspace to restart your X window server, but that's overkill. A better idea is to press Ctrl+Alt+F2 to take you to a virtual terminal. You can log in by entering your username, then you'll be prompted for your password. Once you've logged in, enter the following command:
top

This displays a list of the running applications. It includes details of how much memory and CPU each is using. Look for the application you want to stop, and note the PID (process ID) number. Then press Q to exit top.

Now you know this number, it's easy to kill the process from the command line. If this number was 1234 for the program you wanted to stop, you'd enter the following:
kill 1234

Easy! Now press Ctrl+Alt+F7 and you'll be back at your desktop as usual, minus the hung application.

Mounting partitions and other devices from the command line

Many Linux users dual-boot with another operating system, and it can be inconvenient if you can't get access to the files you have in that partition. For instance, if you are dual booting Windows XP and Ubuntu, perhaps you'd like to be able to play some music from your hard drive in Rhythmbox, but you can't get at it. Ubuntu is pretty good at mounting new filesystems automatically, but it's not perfect, so it pays to take the time to learn how to do it yourself. Don't worry, it's not that hard!

If it's an external device such as a flash drive that you want to mount, then connect this. Then run the following command in the terminal:
sudo fdisk -l

This will display all the filesystems that your system can detect, whether they are mounted or not. For example, here's mine on my Kubuntu laptop:
matthew@matthew-laptop:~$ sudo fdisk -l

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0008acac

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2918 23438803+ 83 Linux
/dev/sda2 2919 3042 996030 82 Linux swap / Solaris
/dev/sda3 3043 4864 14635215 83 Linux
matthew@matthew-laptop:~$

Don't worry if this looks confusing. All you need to look for is the Device and System columns. The system column shows the filesystem used - this can be handy as different operating systems use different filesystems, so it would be easy to recognise a Windows-formatted partition - it would show as something like FAT or NTFS. The device column shows the device each partition is on - /dev/sda is the hard drive. /dev/sda1 is one partition, /dev/sda2 is another and so on. A different device would show up as something else, such as /dev/sdb, and its partitions might show as /dev/sdb1 and so on.
So you should have no problem identifying which partition it is you want to mount. Once you know this, we can get started. If you remember from an earlier lesson, Linux will happily slot a new partition in anywhere you tell it to, you just have to say where. It's best to put it in the /media directory if it's something temporary like a flash drive, whereas /mnt is better for more permanent things like your Windows partition. You'll need to create a directory in which to mount it to make it easier to manage, something like this:
sudo mkdir /mnt/windows

Then, once that's done, you can issue the command to mount the partition there. If the Windows partition was /dev/sda3, you could mount it in /mnt/windows as follows:
sudo mount /dev/sda3 /mnt/windows

Once this is done, you should be able to browse the newly added partition or device with ease. If you want to remove it manually, issue this command:
sudo umount /dev/sda3

If you'd like to mount something automatically when you boot up, such as your Windows partition, you can install the pysdm package. Then open the new Storage Device Manager, which will enable you to easily set up partitions to mount at boot, and specify where you want them.

Adding Google Gadgets to your desktop

One thing some people may miss from other operating systems is desktop widgets. There's several ways to get these in Ubuntu and its derivatives. For Gnome users, there's the gdesklets or screenlets packages. For KDE3 users, there's superkaramba, and if you're using KDE4 there's plasmoids available - just add the extragear-plasma package.
Now there's a new way to get desktop widgets, and this way gives you access to a huge cross-platform library of widgets. This is of course Google Gadgets. It's long been missing from Google Desktop on Linux, but now it's available separately.
I'm not going to tell you how to set this up because the people at Ubuntu Unleashed have written a great guide to this, which is available here. You should already know how to add third-party repositories, so I'm comfortable leaving you to head there if you want to install Google Gadgets for Linux.