Linux who, w, and whoami Commands

In Linux, the who utility is used for determining the time of the last boot of the operating system (list of logged-in users). The “w” utility is used for printing activities like user id on the operating system that also prints the system’s running time and load average. The “whoami” (combination of three words “who”, “am”, and “i” is the command that displays the name of the currently logged-in user.

This article will demonstrate the usage of the who, w, and whoami commands in Linux. The content for the post is:

How is the who Command Used in Linux?

As mentioned earlier, the “who” is the built-in utility for displaying the list of logged-in users. The syntax for the who command is shown below.

Syntax:

$ who [Options] [Files | arg 1 ..arg 2]

Type the “who” keyword, “options” along with the who command, and file arguments if necessary.

Run the help command in the terminal to display the various options that can be utilized for the who command:

$ who --help

All the options for the who command have been listed.

Let’s move and check the working of the who command in Linux.

For printing the information of the logged-in user, run the “who” command in the terminal:

$ who

All the logged-in users will be listed. In our scenario, there is only one logged-in user, “itslinuxfoss”.

For printing the status of the user’s messages, run the given command:

$ who -T -H

The users’ messages will be printed with a “+” sign.

To display the system boot time, use the “b” flag in the command:

$ who -b -H

The system boot time will be printed.

To display the dead processes of the operating system, use the “d” flag in the command:

$ who -d -H

The dead processes will be displayed. In our case, there is no dead process.

To display the run-level of the operations system (state of the machine after boot) use the “r” option:

$ who -r

The above image shows the operating system is running on level 5

For displaying the count of presently logged-in users, use the “q” option:

$ who -q -H

The number of counts for the logged-in user will be printed.

How is the w Command Used in Linux?

To use the “w” command in Linux, simply type it in the terminal. It will display the activities of the user and the average load of the operating system:

$ w


The activities of the user and average load of the

How is the whoami Command Used in Linux?

To use the “whoami” command in Linux, type it in the terminal to display the currently logged-in user:

$ whoami

The currently logged-in user is “itslinuxfoss”.

To check the version of the whoami utility, run the given command:

$ whoami --version

Conclusion

In Linux, “who” is the utility for determining the last boot, the “w” command displays the activities and average load, and the “whoami” command prints the name of the currently logged-in user. This write-up has illustrated the usage of the who, w, and whoami commands in Linux operating systems.