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.
Here is an example:
$ su Password: # reboot bash: reboot: command not found # adduser bash: adduser: command not found
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
Excerpt from the
man sumanual 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
--login swith. Example:
$ su - OR $ su -l