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.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


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.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions