What’s the difference between “su” and “su -“

5,922

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/

Share:
5,922
Anonymous
Author by

Anonymous

I'm a long-time Stack Overflow user, but I'm now mainly participating in SF&F Stack Exchange. I visit Stack Exchange every day and help out when I can. I edit, review and post often an am the creator of Anynobot, a chat bot and made TeamMod. If you want to talk to me, ping me in whatever room I'm in. Feel free to join me on Discord!

Updated on September 18, 2022

Comments

  • Anonymous
    Anonymous over 1 year

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

    • John1024
      John1024 almost 6 years
      Did you look at man su? If so, what part of its explanation did you find confusing?
    • Jason Bassford
      Jason Bassford almost 6 years
      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 . . .
    • Anonymous
      Anonymous almost 6 years
      @Jhon1024, I did not think to read the man su file. Maybe I should have.
    • jdhao
      jdhao over 4 years