Learn Difference Between “su” and “su -” Commands in Linux

In an earlier article, we have explained to you the difference between sudo and su commands in Linux. These are two important commands used to implement security in Linux, in regards to user management policy and user permissions.

The su command is used to switch to another user, in other words change user ID during a normal login session (that is why it is sometimes referred to as switch (-) user by a number of Linux users). If executed without a username, for example su -, it will login as root user by default.

A common challenge faced by new Linux users is understanding the difference between “su” and “su -“. This article will help you briefly understand the difference between “su” and “su -“ in Linux systems.

Usually, to become another user or login to other user, you can invoke the following command, then you will be prompted for the password of the user you’re switching to.

$ su tecmint
Switch Users in Linux
Switch Users in Linux

Considering the scenario in the screenshot above, it is significant to note that the user tecmint keeps the environment from user aaronkilik’s original login session, the current working directory and the path to executable files also remain the same.

As a result, when user tecmint tries to list the working directory (which is still user aaronkilik’s working directory), the error: “ls: cannot open directory .: Permission denied” is displayed.

But at the end, user tecmint can list his home directory after running cd command without any options.

Secondly, when you invoke su with a -, or -l or --login flags, it offers you a login interface similar to when you are logging on normally. All the commands below are equivalent to each other.

$ su - tecmint
OR
$ su  -l tecmint
OR
$ su --login tecmint

In this case, the user tecmint is provided his own default login environment, including path to executable files; he also lands into his default home directory.

Login as Different User
Login as Different User

Importantly, when you run su without a username, you will automatically become the superuser. You will be given root’s default environment, including path to executable files changes. You will also land into root’s home directory:

$ su

Also check out: How to Show Asterisks While Typing Sudo Password in Linux

We hope you find this article informative. You can ask any questions or share your thoughts via the comment section below.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

16 thoughts on “Learn Difference Between “su” and “su -” Commands in Linux”

  1. You didn’t answer the question of the title of the article and you gave erroneous information (for my Debian installation).

    su – will ask for the root password and switch me to root user and give me the root environment, pwd shows /root

    su (without the dash) will ask for the root password and switch me to root user and leave me in the original user’s environment, pwd shows /home/originaluser

    Reply
  2. The article does NOT answer the question posed: What is the difference between “su” and “su –“?

    E.g., on Sparky Linux, if you switch to root in a terminal by “su” then the root password, you will NOT get access to “swaplabel“. One has to switch to root as “su –” and the root password NOT simply “su” in order to be accorded all root paths.

    The question was simple, so’s my answer.

    Reply
  3. From the manpage of ‘su‘ (on opensuse).

    #####8<#####
    NAME
    su – run a command with substitute user and group ID

    SYNOPSIS
    su [options] [-] [user [argument…]]

    DESCRIPTION
    su allows to run commands with a substitute user and group ID.

    When called without arguments, su defaults to running an interactive shell as root.

    For backward compatibility, su defaults to not change the current directory and to only set the environment variables HOME and SHELL (plus USER and LOGNAME if the target user is not root). It is recommended to always use the
    –login option (instead of its shortcut -) to avoid side effects caused by mixing environments.
    #####8<#####

    So, the su means 'switch user', with the default user being the "top" administrative user, as Aaron explains

    Reply
    • @Jonix

      We do not have to copy and paste the definition from man pages in our articles, we simply explain in terms users can easily understand and relate with. Of course, you can always find more information in man pages.

      And different distros offer different command/program descriptions. For example on Ubuntu or Linux Mint, the man page says:
      “NAME su – change user ID or become superuser”

      Thanks for sharing your thoughts with us.

      Reply
  4. su without a username and you become the root user not super user. There is no such thing as super user, just root user. That super user crap started years ago and is still perpetuated. sheesh

    Reply
    • @Marshall

      I guess we have fallen victims of using superuser to mean root user. However, the two words “root” and “superuser” are used interchangeably in relation to Unix/Linux operating systems today. According to Wikipedia, “superuser is a special user account used for system administration. Depending on the operating system (OS), the actual name of this account might be root, administrator, admin or supervisor.”

      Thanks for sharing your concern with us.

      Reply
      • During the install, some distros ask if the first user created is to be the administrator. If you say YES, that user becomes the superuser but he DOES NOT become the root.

        Reply
        • @dragonmouth

          Yes, this is correct. But in the article, we are referring to root as the superuser(vice versa), who has absolute permission to perform any kind of task on a Linux system, without using sudo command.

          Thanks for pointing this out.

          Reply
  5. One interesting thing that can be done with sudo is starting a “longtime” shell by issuing ‘sudo bash‘ ; instead of issuing root-claimimg commands one at a time (do remember to logout of this subshell when finished, to avoid stupid things done with the power-of-root)

    Reply

Leave a Reply to Larry De Coste Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.