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?
Asked
Active
Viewed 261 times
0
Gilles 'SO- stop being evil'
- 829,060
Jim
- 10,120
1 Answers
0
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.
124
- 324
-
1My question is why do we even need
su Johnnot 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 – Jim Jan 30 '14 at 07:28 -
su userwould be. Why wouldn't one want to usesu - userinstead. Not what the difference between the two is. – terdon Jan 30 '14 at 15:01