Cart 0
No products in the cart.

How to use whoami command in Linux ?

How to use whoami command in Linux ?

The "whoami" command is a command-line utility in Linux that allows users to determine their current user name. It is a useful utility for administrators who need to quickly determine which user is currently logged in on a particular machine.

Here at Fixwebnode, we shall look into a detailed overview of the "whoami" command and provide 6 practical examples of its usage.

 

What is whoami Command ?

The "whoami" command is a Linux command that is used to identify the user currently logged in to a given computer. It prints out the name of the user and the user's id. It is a useful utility for administrators who need to quickly determine which user is logged in on a particular machine.

 

whoami Command Syntax

The syntax for the “whoami” command is as follows:

$ whoami [options]

 

whoami Command Options

The command supports the following options:

  • -h, --help: Display help information 
  • -V, --version: Display version information 
  • -a, --all-sessions: Display information about all sessions 
  • -s, --show-sysname: Display system name

 

Examples of using whoami Command

Now that we have covered the basics of the "whoami" command, let’s take a look at some practical examples. 

 

1. Display User Name

To display the user name of the current user, simply run the following command:

$ whoami

This command will print out the name of the currently logged in user.

 

2. Display System Name

To display the system name, use the "--show-sysname" option:

$ whoami --show-sysname 

This command will print out the system name.

 

3. Display Information About All Sessions

To display information about all sessions, use the "--all-sessions" option:

$ whoami --all-sessions

This command will print out information about all sessions.

 

4. Display Help Information

To display help information about the "whoami" command, use the "--help" option:

$ whoami --help

This command will print out help information about the command.

 

5. Display Version Information

To display version information about the "whoami" command, use the "--version" option:

$ whoami --version

This command will print out version information about the command.

 

6. Combining Options

The options can also be combined in order to achieve more complex results. For example, to display help information and version information at the same time, use the following command:

$ whoami --help --version

This command will print out both help information and version information.

 

[Need Tech support ? We can help you. ]

 



CONCLUSION

This tutorial provided an overview of the “whoami” command and 6 practical examples of its usage. The command is a useful utility for administrators who need to quickly determine which user is currently logged in to a particular machine. With the examples provided, you should now have a better understanding of how to use the "whoami" command in Linux.

 

How to fix whoami command not found in Linux ?

Whoami is a command used to display the currently logged in user in Linux terminal. If you receive the message "whoami: command not found" when trying to run the command, it means that the command is not installed on your system. You can fix this issue in a few simple steps.

 

1. Check for whoami on your system

The first step is to check if the whoami command is installed on your system. To do this, open the terminal and type "which whoami". If the command is installed, you will see the path to the executable file, otherwise you will see "no whoami in".

 

2. Install whoami

If the command is not installed, you can install it with the following command:

$ sudo apt-get install whoami

This command will install the whoami package on your system.

 

3. Verify the installation

Once the installation is complete, you can verify that the command is working by typing "whoami" in the terminal. If the command is working, you will see the currently logged in user.

 

That's it. You have successfully fixed the "whoami: command not found" issue in Linux.

 


icon

Sign up to Newsletter

...and receive a free support ticket.