Colourful man pages in Ubuntu

Linux, Man pages, Ubuntu July 21st, 2008

Linux man pages are the most important resource for a Linux freak. By default man pages are formatted using the ‘less’ utility. ‘less’ shows the man pages in black & white, something like this :

grayscale man pages

If you use ‘most’ utility to format man pages, you will get a properly colour-formatted man pages. Take a look at man pages configured on my system :

color man pages

Do you like this one ?? Read on how to configure ‘most’ as your man pages viewer.

Step 1: Install the package ‘most’

$ sudo aptitude install most

Step 2: Configure ‘most’ as your man page viewer using update-alternatives :

$ sudo update-alternatives --config pager

update-alternatives

Enter the number corresponding to /usr/bin/most , here in this screenshot its 5.

Yeah, its done. Nothing more to do !!

Have fun.

Let me know if you find any difficulty doing this.

P.S: This can be done in Fedora as well as other linux also. In Fedora I guess you will have to use the command  /usr/sbin/alternatives instead of update-alternatives as root. Somebody try out in Fedora and let me know.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

GRUB Tutorial for Beginners

GRUB, Linux July 20th, 2008

Linux newbies often get frightened by GRUB errors. This article will give you an insight of “What the hell is this GRUB ??” and may also help you solve you many GRUB errors.

What is GRUB ??

GRUB is a boot loader.  Now, you *might* be asking what is boot loader (calm down! you would get to know as you read on.)

FYI: GRUB stands for GRand Unified Bootloader.

How does GRUB work ??

During the boot process, BIOS transfers its control to the booting device according to the priority set in the BIOS. For the sake of simplicity, let us assume that our first boot device is our hard disk.

The first sector of Hard Disk is called the Master Boot Record (MBR). This sector is only 512 bytes long. It contains the partition table (64 bytes) describing the primary and extended partitions and the primary boot loader (446 bytes). Now you can figure out, why there can be only 4 primary partitions or 3 primary partitions and 1 extended partition. (Size of partition table is fixed)

GRUB replaces default MBR with its own code. But GRUB is too big to fit in MBR, so it works in stages.

STAGE 1 : This stage either points directly to STAGE 2 or it points to STAGE 1.5 which loads STAGE 2. STAGE 1.5 is stored immediately after MBR. STAGE 2 can be located anywhere on the disk.

STAGE 2 : This stage contains all the configuration files which results is complex user interface and menus we normally see.

GRUB Naming Conventions

The naming convention used in GRUB is bit different from Linux and Windows.

Following examples will clarify the naming convention rules -

(fd0)

The device name must be enclosed in ‘(‘ and ‘)’ . The ‘fd’ part means floppy disk and similarly ‘hd’ means hard disk. The number 0 indicates the drive number which starts from 0. This expression means the grub will use the entire floppy disk.

(hd0,1)

hd means Hard Disk. The 0 here indicates the drive number that is the first hard disk. And the integer 1 here indicates the partition number. Here again partition number starts from 0. So, 1 indicates the 2nd partition.  This expression means the second partition of the first hard disk. In this case GRUB uses only one partition of the hard disk.

(hd0,4)

This expression specifies the first extended partition of the first disk. Important point to note is that, the partition number for extended partitions are counted from 4, regardless of the actual number of primary partitions on the disk.

Another point to note is that GRUB does not differentiate between IDE and SCSI drives unlike Linux.

GRUB command line interface has TAB completion feature. For example :

grub> root (

If you press <Tab> at this point, GRUB will display the list of drives and partitions.

To specify a file we write like this:

(hd0,0)/vmlinuz

This expression means the file vmlinuz in the first partition of the first disk. Tab completion works with file names as well.

Now let use explore few configuration files of GRUB

How to change the GRUB menu ?

GRUB menu that we see when we boot a system with Linux is generated from the file

/boot/grub/menu.lst

Lines starting with a hash (#)  is a comment. One can safely edit this file to customize the menu that we see at the start up. Let us quickly analyze this file.

Here’s a screenshot of my menu.lst file :

Grub Menu Config file

At the top you will find a line (this line is not visible in the above screenshot):

default 0

This sets the default entry, i.e. the the Operating System that will load by default if you do not press any key for a specified number of seconds.  Here 0 signifies the first entry in the menu. As usual numbering starts from 0.

Another line you will se somewhere near the above line is

timeout 3

This sets the timeout in seconds, before automatically booting the default entry starts. Here 3 signifies three seconds. You can easily change 3 with any number according to your convenience.

Another optional line is

hiddenmenu

If this line is present, menu will not be displayed by default. This is by default set in Ubuntu and unset in Fedora.

We can have a colorful GRUB menu by setting this line :

color cyan/blue white/blue

Syntax of this line is

color normal [highlight]

The colour normal is used for most lines and the color highlight is used for the lines where the cursor points. Highlight color is optional. By default, the inverted colour of normal is used for highlighted line. The format of a color is foreground/background. The colors that can be specified here are limited and can be found in GRUB manual pages. We can even have different menu items in different colours. I will write about coloured GRUB menu in some other post. Stay Tuned ! ;)

Now lets come straight to the menu items. Consider an example:

title        Ubuntu 8.04.1, kernel 2.6.24-19-generic
root        (hd0,0)
kernel        /boot/vmlinuz-2.6.24-19-generic root=UUID=ee3978bb-3563-4445-a6c4-6ba90675cbac ro quiet splash
initrd        /boot/initrd.img-2.6.24-19-generic

  • title: This one is simple. Simply edit it and get your own custom title for every menu entry.
  • root (hd0,0) tells grub to look in the 1st partition of 1 disk.
  • kernel specifies the location of  kernel image
  • initrd is the temporary file system image

There can be many blocks like the above one in your menu.lst file. To remove any entry from the GRUB menu, comment the entire block by placing a hash (#) at the beginning of every line.

And take a backup of menu.lst file before making any changes.

Booting from GRUB command line interface.

Sometimes when you delete a partition or resize a partition or … bla bla … and then restart you computer you see an error like

GRUB error 22 …..

or may be some other error and u see a grub prompt like this

grub>

To boot for the grub prompt follow the following steps:

You need to know which disk and which partition contains your kernel image.

grub> root (

press <tab> at this point and the all disk and partitions will be displayed. enter the correct partition at the prompt. Say for example linux kernel image is on the first partition of first disk.

grub> root (hd0,0)

grub> kernel /vmlinuz-.. root=/dev/sda1 ro

this loads the kernel. Here also you can use tab completion feature to find the exact filename. You can specify some other options like ro , vga etc. After this just enter boot :

grub> boot

And voilla ! you see your linux booting.

If you use initrd, execute the command initrd after kernel at grub prompt like this :

grub> initrd /initrd.img-…

Again Tab completion helps you in completing the file name.

Booting Windows from GRUB prompt:

Say for example windows is installed on 1st partition of first hard disk.

grub> rootnoverify (hd0,0)

grub> makeactive

grub> chainloader +1

grub> boot

Woow.. you see your Windows booting normally.

There’s a lot more about this GRUB. If you are interested in learning more read the GNU GRUB Manual . I also learnt from this manual only.

If you want me to explain any particular thing in this post drop down a comment.

And even if you find any mistakes please drop down a comment.

…………

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

Google’s Advice to Students

Google July 16th, 2008

I was just going through the Google Official Blog and saw this latest post labeled :

Our Googley advice to students: Major in learning

Check out the link.

I am sure you will get to know what Google expects from you as an employer.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

Gedit : A Powerful Light-Weight IDE

GNOME, Linux, Uncategorized July 15th, 2008

Gedit can be transformed into a powerful light-weight IDE.

Before I tell you the steps take a look at the screenshot of my gedit:

gedit IDE

Now, if you are convinced that you also want to customize gedit read on …..

Step 1: Go to edit->Preferences and tick the options :

  • Display line numbers
  • Highlight current line
  • Highlight matching bracket

Step 2:  Click the ‘Editor’ tab in the preferences dialog box. Tick the option :

  • Enable Automatic indentation
  • [optional] change tab width to 4 or whatever width you think is appropriate for you.

Step 3: Download the darkmate theme : http://grigio.org/files/darkmate.xml Save the xml file on your desktop. Click the ‘Font & Colors’ tab in the Preferences dialog box. Click the Add button and then add the xml file downloaded just now. Darkmate theme should now be in the list of Color Scheme. Select the Darkmate theme. Or you can select any Color Scheme you like. You can get more themes from http://live.gnome.org/GtkSourceView/StyleSchemes

Step 4: Now install the package gedit-plugins . This can be accomplished by

$ sudo aptitude install gedit-plugins

(in Debian based system)

or

$ su

# yum install gedit-plugins

(in rpm based system)

After installing the gedit-plugins package open the tab ‘Plugins’ in the Preferences dialog box.

Tick the following plugins:

  • Bracket Completion – This will automatically print right brackt/parantheses for every left counterpart.
  • Code Comment – This plugin helps you in commenting a block of code
  • [optional] Color Picker – This is helpful for web designers to get the color code.
  • Draw Spaces – This plugin will draw an arrow for every tab and one dot for every space. You can configure the color of the space or tab by clicking the “Configure Plugin”
  • Embedded Terminal – This will embed a gnome-terminal at the bottom of your gedit window.
  • Execute Tools
  • File Browser Pane
  • Indent Lines – This plugin helps you in indenting a block of code.
  • Session Saver – This plugin helps you save different sessions.

You can check out other plugins according to your need.

Step 5 : You can get more gedit plugins like “Word Completion” and many more useful 3rd party plugins on this page – http://live.gnome.org/Gedit/Plugins

Download whatever plugin you wish and just place the extracted files in ~/.gnome2/gedit/plugins

You are done !

P.S: Please let me know if you find a useful plugin for gedit.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce

Google Trend Manipulation

Google July 14th, 2008

Google Trend Abuse/Manipulation/… whatever :

Google Trend Abuse

Link to this page : http://www.google.com/trends/hottrends?sa=X&date=2008-7-13

P.S: Last week it was swastika on google trends.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • Facebook
  • TwitThis
  • Live
  • Technorati
  • Furl
  • Sphinn
  • blogmarks
  • LinkedIn
  • Pownce