Sunday, February 16, 2014

Removing old linux kernel images in Ubuntu

To see how many linux kernel image versions you have, do ls /lib/modules. You will see a list of directories (e.g. 2.6.32-51-generic, 2.6.32-52-generic, etc.)---one directory per kernel image version.

Note down the versions that you want to remove (usually, you should keep the last two versions---the last one for normal booting, and the previous one as a fallback).

Open Synaptic. Search for the version number (e.g. "2.6.32-51"). Scroll down the entries for the kernel image and kernel headers, e.g.
  • linux-image-2.6.32-51-generic
  • linux-headers-2.6.32-51-generic
  • linux-headers-2.6.32-51
Usually three entries of the kind mentioned above will be shown as installed in Synaptic. Choose each one, and "Mark for Complete Removal". Apply the changes.

After the Synaptic finishes applying the changes, you can see that the corresponding directories have been deleted from /lib/modules. The next time you start Ubuntu, the removed kernel images will not appear in the (GRUB) boot menu.

Wednesday, February 5, 2014

Using bc in calculations

To use the linux command bc for calculation in shell programs, do the following:
  • Add the line scale=2 to the file ~/.bcrc.
  • Then use var1=`echo "($var2+$var3)/$var4" | bc` to set var1.
Here
  • The scale parameter tells bc to use 2 decimal digits.