Editing GRUB menu in ubuntu 10.04 and above.

1. Open a terminal.

2. Type in

sudo update-grub

Type in your password.

3. Go to the directory /boot/grub. To do this type

cd /boot/grub

4. Here if you type ls, a lot of files will be there. Fortunately, we’re only interested in grub.cfg.

5. Open grub.cfg with a text editor. To do this type

sudo gedit grub.cfg &

(The ampersand sign (&) is to run the gedit program in the background while we can use the terminal for other purposes. Try executing the above command without the ‘&’ sign and you will understand)

6. In there, find the following line

### BEGIN /etc/grub.d/10_linux ###

7. From the beginning of this line, select till the end of the file. The last line of the file will be

### END /etc/grub.d/40_custom ###

8. After you have selected it, copy it. Right-click, copy will do.

9. Now go back to the terminal and go to the /etc/grub.d directory. To do this type

cd /etc/grub.d

10. In this directory, type ls to see the files present. There will be a file called 40_custom. Open this up using the following command

sudo gedit 40_custom &

11. There will be a few lines at the top. Don’t worry. Just paste whatever you copied from grub.cfg over here. Right-click, paste will do.

12. After you have pasted, look closely at it. There will be something similar to the following

menuentry ‘Ubuntu 10.04 Lucid Lynx right here!!’ –class ubuntu –class gnu-linux –class gnu –class os {
    insmod ext2
    set root='(hd0,9)’
    search –no-floppy –fs-uuid –set cafb13dd-92cd-4618-acfe-de02a0ca49e5
    linux    /boot/vmlinuz-2.6.32-28-generic root=UUID=cafb13dd-92cd-4618-acfe-de02a0ca49e5 ro   quiet splash
    initrd    /boot/initrd.img-2.6.32-28-generic

The difference will be in what is written in between the quotes. You can change that to whatever you want displayed on the grub menu.

Also for whichever entries you want removed from the grub menu, just delete the corresponding menuentry blocks from the 40_custom file. Deleting a menuentry block means deleting the block starting from the words ‘menuentry’ till ‘}’.

Once you’ve done enough modifications, save the file and close it.

13. Now the terminal is staying in /etc/grub.d itself right? Run the following command from there.

sudo chmod -x /etc/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober

14. Alright you’re almost ready to go. Just do one more thing.

sudo update-grub

15. Ah good. Restart your system and you will see your own grub. 🙂 Good luck. 🙂

For more detailed description (and a description that makes much more sense too), please visit


Thank you! 🙂


7 thoughts on “Editing GRUB menu in ubuntu 10.04 and above.

  1. Of course we can do that. But it is highly recommended that we do not tamper with the .cfg file directly. It is automatically generated when ‘sudo update-grub’ is run using the files from grub.d.
    However it is not impossible to edit grub.cfg directly.

    PS: Do you know why it is recommended that we don’t change that file manually?

    • I think the other way, If we edit the grub.cfg file directly, we can roll back the changes using update-grub, right? A more safer way? 🙂

      “However it is not impossible to edit grub.cfg directly.”
      What’s the issue? There’s no problem in saving the changes directly in grub.cfg, is it?

      I think why we are not supposed to change the grub.cfg is because, it’s not permanent (changes automatically on update-grub) and it follows a definite syntax generated by grub commands – which is very different from older version of grub. I’m not sure about the reason, will try to know somehow and post here.

  2. The update-grub command automatically generates the /boot/grub/grub.cfg file by reading default settings from /etc/defaults/grub and running shellscripts in /etc/grub.d

    for example, the 10_linux file of grub.d contains the following code:

    linux_entry ()
    if ${recovery} ; then
    title=”$(gettext_quoted “%s, with Linux %s (recovery mode)”)”
    title=”$(gettext_quoted “%s, with Linux %s”)”
    printf “menuentry ‘${title}’ ${CLASS} {\n” “${version}”
    . . . . . . .
    . . . . . . .

    The code for grub-menu(in grub.cfg) produced during update-grub cmd will be according to this code. If we want to change grub-menu text, we have to change this in grub.d (or, more appropriately in 40_custom). So even if we change grub.cfg directly, it can only last till next grub update.

  3. Pingback: Recovering Grub after installing Windows using Ubuntu. « A 'psycho' path.

  4. Was searching for a way to clean mymenu (5 different OSs) without editing grub.cfg,
    and you gave me the answer. Brilliant! Thanks very much.

Hey! What do you think? Share your thoughts. :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s