When we do su John
I switch as user John.
When we do su - John
I switch as user John having user John's environment.
As far as I can see the first option is useless. What is the use of switching to another user and not have that user's environment?
Am I wrong? What is the difference in use cases between these 2 options?
1 Answer
su John
if you use su John
only then basically you just temporary "borrow" the John
permission without having all the John
environment setting. You will notice that you are not having sbin path. Which means some John
commands you issue at this environment might not work.
su - John
when you use su - John
command, you are given a new login shell from the Linux server, which is the same as you logout from the existing user and perform a fresh login.
-
1My question is why do we even need
su John
not what is the difference."...only then basically you just temporary "borrow" the John permission without having all the John environment setting" This seems useless to me– JimJan 30, 2014 at 7:28 -
su user
would be. Why wouldn't one want to usesu - user
instead. Not what the difference between the two is.