Command not found – Missing path to /sbin on Debian GNU/Linux

Starting with Debian 10 buster the way how the su command is used has been changed. By default execution of the su command no longer provides you with expected user environmental variables.

In the case of a simple switch to administrative user root by executing su with no arguments the expected root’s PATH variable is no set properly.

Symptoms

Here is an example:

$ su
Password:
# reboot
bash: reboot: command not found                                                                        
# adduser                                                            
bash: adduser: command not found
bash: reboot: command not found  - Debian GNU/Linux missing path to /sbin/ directory

bash: reboot: command not found – Debian GNU/Linux missing path to /sbin/ directory

Solution

The trick on how to fix this inconvenience is to explicitly tell the su to set environment variable as if the user logs in directly. This is can be done by the use of - switch.



NOTE
Excerpt from the man su manual page. -, -l, –login will provide an environment similar to what the user would expect had the user logged in directly.

To set a correct path for the root user user make sure to execute the su command with - or -l or --login swith. Example:

$ su -
OR
$ su -l
Debian su command execution to gain root access

Note the different PATH settings for both attempts to gain a root access using su command.