Sunday, August 31, 2008

Empty Applications Menu? Repopulate it.


All of a sudden, one fine morning I found that the Applications Menu in GNOME on my Ubuntu 8.04 laptop was empty. When I clicked on the Applications Menu, all I got was a small rectangular box, about a few pixels in dimensions. I found a solution to this, (the solution was the first result that Google threw at me). This problem seems to occur when there is not much hard disk space left. When this occurs, you are unable to run alacarte even from command prompt.
The solution is to delete the applications.menu file from ~/.config/menus/ directory.
$rm ~/.config/menus/applications.menu
After this the Applications Menu is restored.

Saturday, August 23, 2008

ls tips - 1

Sometimes it becomes necessary to search for all files that end in a particular character, like, for example a digit. The following command will list out all files that have filenames ending in a digit -
$ ls | grep '[0-9]$'

It is essential that the $ symbol is placed after the paranthesis. This $ symbol will cause grep to look for the digits from 0 to 9 at the end of the filename.
A better way would be -
$ ls | grep '[[:digit:]]$'

Similarly, if you want to search for filenames that begin with a digit, here is the command -
$ ls | grep '^[0-9]'

or
$ ls | grep '^[[:digit:]]'

This will list all filenames that begin with a character.

Friday, August 22, 2008

Giving Maximum processing time to any process

To give maximum processing time to any process, first the PID of the process has to be determined using the command ps. Say you have firefox running and you want to determine its PID.
$ ps -A | grep firefox

on my system gives the following output
12845 pts/0 00:04:00 firefox

so 12845 is the required PID.
By issuing the following command we can give maximum priority (-20) to the particular process -
$ sudo renice -20 12845
This can be ascertained using the 'top' command.

Re-installing GRUB in Ubuntu


Imagine a scenario, wherein you have installed a brand new distro on a system that already has some other distro installed. You have properly configured the GRUB to enable you to multi-boot. Now for some reason, you do not like the GRUB of the distro that was last to be installed, you want to revert back to the previous one. So what do we do now?
The solution is to boot into the required distro from the GRUB menu and then follow these steps -
1. Login as root from the command prompt and enter the following command
# sudo grub
grub > find /boot/grub/stage1


Let us say, the command returns (hdx,y).
2. Then enter the following commands -
grub > root(hdx,y)
grub > setup (hdx)
grub > quit


That's it! When you reboot, you'll be presented with the previous GRUB screen.