debian9.6中update-grub找不到的解决办法及它与update-grub2的区别

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。

参考:https://www.cnblogs.com/EasonJim/p/7471650.html

猜你喜欢

转载自blog.csdn.net/weixin_39465823/article/details/86539580