FactorPad
Faster Learning Tutorials

Linux whoami command summary with examples

whoami allows you to display the current user's name.
  1. Purpose - Learn what whoami is for an how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with whoami.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 9, 2016
Updated: July 26, 2018
In this tutorial, 13 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  / whoami command


The Linux whoami command

Beginner

Learn to find your user id at the Linux command line.

Video Tutorial

Linux whoami command summary with examples (3:39)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our thirteenth word, or command to memorize is whoami from the category Users.

whoami allows you to display the current user's name. Recall from our last video, we created the alias lsd, and that led us to kick off this, our first discussion on users. And with that as an opener...

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

The whoami command has 2 options and no arguments, so it's one of the simplest commands we'll cover.

We'll touch on the self-explanatory double-dash options shortly (--help and --version).

So why is whoami an important command? Well, for those with multiple identities, like system administrators, whoami provides a quick command offering an opportunity for self-reflection. And now you know how to do that.

Demonstration

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, type whoami.

$ whoami paul

And look, the computer knows me by my name paul. Isn't that nice? Well, actually, Linux translates every user into a numeric userid called a UID, which we'll explore later.

Next, the --help option.

$ whoami --help Usage: whoami [OPTION]... Print the user name associated with the current effective user ID. Same as id -un. --help display this help and exit --version output version information and exit GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Full documentation at: <http://www.gnu.org/software/coreutils/whoami> or available locally via: info '(coreutils) whomi invocation'

And this offers an introduction to an advanced command to be discussed later, called id.

And at this point, I'd like to draw your attention to a common option, used across many commands, the double-dash --version.

$ whoami --version whoami (GNU coreutils) 8.23 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Richard Mlynarik.

Pretty easy huh? As you can tell, I wanted to approach the topic of users slowly, because often the subject is best left to the experts.

A Final Tip

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

One last tip about the whoami command. So whoami is the second of the who, what, where, when, why, how questions offering perspective that we cover here. Can you guess what command comes next?

Okay, thanks for visiting today. I hope this was a fun introduction to the whoami 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?

If you like to learn, click to subscribe.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the alias command, hit Back.
  • To find locations of files using the whereis command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / whoami command



 
 
Keywords:
linux whoami command
unix whoami
linux whoami tutorial
linux whoami examples
linux who am i
who am i command
linux user id
linux uid
user management in linux
shell whoami
terminal whoami
find your user id