Knowledge Base

How To Use The Whoami Command on Linux

The Whoami command prints the username with a valid user ID. This command is able to display the name of the logged in user.

Using whoami

Command syntax

whoami [OPTION]

To display the username, enter the following:

whoami

Next, you will see the username (example – user1):

user1

The command can be used in scripts to verify the name of the user who ran the script. Below is an example of using the if statement to compare the name of the user who runs the script with the given string