1,bash: update-grub: 未找到命令
guoyanzhang@bogon:~$ update-grub
bash: update-grub: 未找到命令
爲什麼呢?我們搜一下:
guoyanzhang@bogon:~$ whereis update-grub
update-grub: /usr/sbin/update-grub /usr/share/man/man8/update-grub.8.gz
明明是有的,但是爲什麼又說找不到呢?注意看/usr/sbin/,不是/usr/bin,我們平時在普通用戶tab出來的是在/bin下,不是在/sbin下,使用/sbin下的,就要使用sudo:
guoyanzhang@bogon:~$ sudo update-grub
[sudo] guoyanzhang 的密碼:
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-8-amd64
Found initrd image: /boot/initrd.img-4.9.0-8-amd64
Found Arch Linux (rolling) on /dev/sda3
Found Debian GNU/Linux 9 (stretch) on /dev/sda4
Adding boot menu entry for EFI firmware configuration
done
2,再看update-grub2
guoyanzhang@bogon:~$ sudo update-grub2
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-8-amd64
Found initrd image: /boot/initrd.img-4.9.0-8-amd64
Found Arch Linux (rolling) on /dev/sda3
Found Debian GNU/Linux 9 (stretch) on /dev/sda4
Adding boot menu entry for EFI firmware configuration
done
結果是一樣的。
3,表面比較
guoyanzhang@bogon:~$ whereis update-grub
update-grub: /usr/sbin/update-grub /usr/share/man/man8/update-grub.8.gz
guoyanzhang@bogon:~$ whereis update-grub2
update-grub2: /usr/sbin/update-grub2 /usr/share/man/man8/update-grub2.8.gz
guoyanzhang@bogon:~$ sudo ls /usr/sbin/update-grub2 -l
lrwxrwxrwx 1 root root 11 10月 29 03:18 /usr/sbin/update-grub2 -> update-grub
update-grub2其實只是一個鏈接符號,鏈接到update-grub。
4,內容比較
guoyanzhang@bogon:~$ sudo cat /usr/sbin/update-grub
#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
guoyanzhang@bogon:~$ sudo cat /usr/sbin/update-grub2
#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
內容其實是個腳本,真正執行的是grub-mkconfig這句,在archlinux上,直接用這句來更新grub。