PDF download Download Article
Easy ways to change to another user in Linux
PDF download Download Article

The "su" command, which stands for "switch user" or "substitute user," makes it easy to change to another user in Linux. Or, if you just want to execute a command as another user without logging in as them, you can use "sudo," or "superuser do." Read on to learn how.

Things You Should Know

  • To become another user in Linux, use su - <username> .
  • To run commands as a different user, use sudo -u <username> <command> .
  • In the GNOME desktop environment, you can change users in the System menu > Power Off / Log Out > Switch User.
Method 1
Method 1 of 3:

Using Su

PDF download Download Article
  1. Use this command to switch to another user at the command line. The "-" indicates that you want to log in as username and assume their environment variables, home directory, and shell preferences. [1] Once you enter their password, your prompt will change to that user's prompt.
    • If you want to change users without changing your shell, omit the hyphen. E.g., su username .
    • sudo – username is the same as sudo -l username and sudo --login username .
    • In some Linux distributions, ( not Ubuntu ), you can use su - (with no username specified) to become the root user . It's better to use sudo to execute root-level commands as needed instead of becoming the root user—you're far less likely to break things.
  2. Advertisement
Method 3
Method 3 of 3:

Using GNOME

PDF download Download Article
  1. It's at the top-right corner of your desktop—where you'll see the network icon, volume, and battery.
  2. This expands more options.
  3. As long as you have at least one more user added to your Linux system, you'll see the Switch User option. [3]
    • When you switch users, the applications you were running will continue to run in the background.
    • You can easily switch back and forth between users as needed.
  4. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

      • Run the whoami command to see which user you're logged in as.
        • If you use su to switch to another user, whoami will report the username you changed to.
        • If you used sudo to run a command as another user, you'll still see your regular login name with whoami .
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Thanks to all authors for creating a page that has been read 5,242 times.

      Is this article up to date?

      Advertisement