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
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.
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