0

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
  • This is not a dupe, the OP is asking what a legitimate use case for su user would be. Why wouldn't one want to use su - user instead. Not what the difference between the two is.
    – terdon
    Jan 30 '14 at 15:01
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.

2
  • 1
    My 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
    – Jim
    Jan 30 '14 at 7:28
  • This explains the concept, but does not answer the question.
    – JZeolla
    Jan 30 '14 at 17:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.