On 2017-06-22 13:38, Dave Plater wrote:
On 22/06/2017 13:10, Carlos E. R. wrote:
On 2017-06-22 11:34, Dave Plater wrote:
Running just "su" alone meremly changes your effective UID. By default, it is to root, but could to to another user. It does not alter HOME, SHELL, USER, LOGNAME, and PATH. That last one is important. A real root shell expects to have /sbin & /usr/sbin in the PATH The only difference between su and su - is $USER is normal user for the
On 18/06/2017 14:31, Anton Aylward wrote: former and is root for the latter.
No, both commands change to "root" as given above. And with both you can change to any user:
su john su - john
What I mean is if you are logged in as user john in any terminal and then you execute su and give the root password, your $HOME is /root and $USER=john but if you execute su - and give the password then your $USER=root. Anton represented plain su as sudo where $HOME remains /home/john.
cer@Telcontar:~> echo $HOME $USER /home/cer cer cer@Telcontar:~> su Password: Telcontar:/home/cer # echo $HOME $USER <=== /root cer Telcontar:/home/cer # exit cer@Telcontar:~> su - Password: Telcontar:~ # echo $HOME $USER /root root Telcontar:~ # logout cer@Telcontar:~> Notice that for "su" the HOME var is /root, but the current directory is not. -- Cheers / Saludos, Carlos E. R. (from 42.2 x86_64 "Malachite" at Telcontar)