Faster Learning Tutorials

Linux su command summary with examples

su allows you to temporarily substitute users.
  1. Purpose - Learn what su is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with su.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, November 9, 2016
Updated: July 23, 2018
In this tutorial, 78 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / su command

The Linux su command


Learn to temporarily change users at the Linux command line.

Video Tutorial

Linux su command summary with examples (3:12)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our seventy-eighth word, or command to memorize is su from our category Users.

su allows you to temporarily substitute users.

Recall from the previous four videos (tutorials) we tackled file permissions and ownership, now we'll attempt to login as another user, say to perform a task.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The su command has 5 options, and the argument is the User ID (name) you'd like to use temporarily.

Like most commands, help is available with double-dash --help. The - or -l option logs in as if you were the other person. -m or -p keeps your own shell, ignoring that person's startup scripts and environment variables.

So why is su an important command? Well, many administrative commands like seeing log files, installing programs and modifying configuration files can only be accessed with new credentials. And now you know how to do that.


Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. In the time we have, let's keep it very simple. Start with su jennifer, enter her password and then a pwd from video (tutorial) 6 to see where we sit.

$ su jennifer Password: $ pwd /home/jennifer

So we switched to her home directory.

Then, let's run a whoami, from video (tutorial) 13.

$ whoami jennifer

And notice how I've taken the identity of Jennifer.

And last, enter the id command from video (tutorial) 77 for Jennifer's group memberships.

$ id uid=1001(jennifer) gid=1001(jennifer) groups=1001(jennifer)

And then to leave her account we'll need to type exit.

$ exit $ _

A Final Tip

Okay now you know how to use su. And you know the syntax for commands, options and arguments.

One last tip about the su command. So I touched on passwords a second ago, which we'll tackle right after one more related and important command.

Okay, thanks for visiting today. I hope this was a helpful introduction to the su command.

Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:

What's Next?

Please join our growing community on YouTube. It's easy subscribe here.

  • To see the Outline of all 100 tutorials, click Outline.
  • To go back to the id command, hit Back.
  • To stick with the User Administration theme and the sudo command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / su command

Linux su command
sudo su
change user Linux
switch user Linux
Linux change user
login as different user
su root
su password
man su