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 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.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

12 Responses

  1. Review says:

    When running su and typing the password it returns “Authentication failure

  2. Jonix says:

    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

    • Aaron Kili says:

      @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.

  3. Marshall Neill says:

    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

    • Aaron Kili says:

      @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.

      • dragonmouth says:

        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.

        • Aaron Kili says:

          @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.

  4. Jonix says:

    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)

  5. Phil Wiggins says:

    And what about”sudo su” and “sudo su -“

Leave a Reply to Jonix Cancel reply

Your email address will not be published. Required fields are marked *

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