0

In a UNIX machine, what is the difference between su and su -? Is there even a difference? I know that su - is the standard.

4
  • 4
    Did you look at man su? If so, what part of its explanation did you find confusing? – John1024 Jun 3 '18 at 20:39
  • I also would not say that su - is the standard. I'd assume that most people who use su do so simply for the root-level permission . . . – Jason Bassford Jun 3 '18 at 20:41
  • 1
    @Jhon1024, I did not think to read the man su file. Maybe I should have. – Anonymous Jun 4 '18 at 21:20
  • Possible duplicate: unix.stackexchange.com/questions/7013/… – jdhao Sep 29 '19 at 10:04
0

Well the su - "Username" or su -1 "username" or su --login "username" (all the same) will give you a login screen, and change paths, home directory, etc..

The su "username" command only chances user, and not home directories (this does not apply to "su no username" because you login has Root / SuperUser, and you will given the root's default environment, including path to executable file changes. You will also land into the root's home directory.) so to answer your question to make sure they are in the right place with the right user?

Ref link : https://www.tecmint.com/difference-between-su-and-su-commands-in-linux/

0

Suppose you are given the following template, where you want to log in as as a new user say john: [sarah@vine ~]$su john Password: [john@vine sarah]$ [john@vine sarah]$ls ls:cannot open directory .:Permission denied

From above, user john kept the environment from user sarah's original login session, the current working directory and the path to executable files also remain the same. As a result if user john tries to list the working directory, he gets an error message denying him permission. However, if su - or su -l or su --login is executed as below, john will be given his own default login environment, that includes path executable files, and he also lands into his own home directory.

[sarah@vine ~]$su - john Password: [john@vine ~]$ [john@vine ~]$ls bin lost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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