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 thesu
to set environment variable as if the user logs in directly. This is can be done by the use of -
switch. Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
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.su
command with -
or -l
or --login
swith. Example: $ su - OR $ su -l