Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm making some changes on my grub file under /etc/defaults/grub in some tutorials I have sudo update-grub and others sudo update-grub2 what is the difference?

share|improve this question

1 Answer 1

up vote 17 down vote accepted

There is no difference.

Ubuntu 9.10 and later have GRUB2 installed, but sudo update-grub has still prevailed as the standard command.

sudo update-grub and sudo update-grub2 are equivalent, so it doesn't matter which one you run. /usr/sbin/update-grub2 is just a symbolic link to /usr/sbin/update-grub.

ek@Del:~$ ls -l `which update-grub update-grub2`
-rwxr-xr-x 1 root root 64 May 17 03:07 /usr/sbin/update-grub
lrwxrwxrwx 1 root root 11 May 17 03:22 /usr/sbin/update-grub2 -> update-grub
  • Actually, generally speaking sometimes one command can be a symbolic link of another, and yet they behave differently, because the executable checks how it was invoked (i.e., by what name) and behaves accordingly.

    That is not the case for update-grub2 and update-grub though, which are both provided by packages like grub-pc that provide GRUB2. Furthermore, /usr/sbin/update-grub is actually just a short shell script that does most of its work through yet another command, and we can look at its complete 3-line source code (in Ubuntu 12.04) to see that the name used to invoke it is not checked:

    #!/bin/sh
    set -e
    exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
    

    "$@" expands to all the command-line arguments passed after the name update-grub or update-grub2, but not that name itself. And this is the only place in the script that command-line syntax is checked at all.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.