Debian 10 Buster | update-grub | command not found

Solutions (best ones first)

  1. su - root instead of su root - nicest solution (thanks to Rui)
  2. extend path of the regular user in /etc/enviroment or ~/.bashrc or similar config file
  3. call commands explicitly; using this solution would require that one modifies all scripts that happens to call another command from sbin (this is not practical, nevertheless there is an example of it in the troubleshooting section)

Findings

This happened because the PATH works in a really strange way (actually works as designed).

  1. regular user login -> environment PATH doesn't contain /usr/sbin => opinion: works as designed, quite logical
  2. su root -> admin rights, but the environment is lacking /usr/sbin:/sbin => opinion: works as designed, but illogical, because an account with root level of access should be able to execute commands from sbin without adding the path to the binaries manually
  3. su - root -> admin rights, /usr/sbin on the path => opinion: works as designed, quite logical

Some more background

There are two PATH defined in /etc/login.defs, but unless I start su - or su - root, I'm going to get the ENV_PATH. I know that this has been designed this way, to keep the environment of the actual user, but in this single case, it really boggles my mind, why not add automatically /usr/sbin and /sbin to thew path of a "regular user" after a successful su root

# cat /etc/login.defs |grep PATH=
ENV_SUPATH  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH    PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Troubleshooting

I've found that there is an update-grub command in /usr/sbin.

# find / -name update-grub
/usr/sbin/update-grub

Ran it, just to get the next error message.

# /usr/sbin/update-grub
/usr/sbin/update-grub: 4: exec: grub-mkconfig: not found

Searched for grub-mkconfig and found it under /usr/sbin/grub-mkconfig. Then it came to me, let's see how the update-grub script looks like?

#cat /usr/sbin/update-grub |grep grub-mkconfig
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"

Modified /usr/sbin/update-grub in order to call grub-mkconfig by it's explicit path ...

exec /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg "$@"

... then called update-grub with it's explicit path and tada, it worked!

# /usr/sbin/update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.18.0-2-amd64
Found initrd image: /boot/initrd.img-4.18.0-2-amd64
Found linux image: /boot/vmlinuz-4.16.0-2-amd64
Found initrd image: /boot/initrd.img-4.16.0-2-amd64
done

Conclusion

This must be something about the PATH

Tags:

Debian

Grub