Linux who, w and whoami Command

16

who command is used to determine when the system has booted last time, a list of logged-in users, and the system’s current run level.

w command displays user information like user id and activities on the system. It also gives the knowledge of the system’s running time along with the system load average.

As the name describes, the whoami command is used to print the user’s name from which they are currently logged-in.

who Command

To display the login name of the user, type the “who” command in the terminal:

To get the status of users messages, type the below-mentioned Command:

Linux who, w and whoami Command 1617497345 982 Linux who w and whoami Command

-b option is used to show when the system boots last time. So, to check its boot time, use the given Command:

Linux who, w and whoami Command 1617497346 620 Linux who w and whoami Command

To display a list of all dead processes in the system, use the -d option with the “who” command in the terminal.

Type the given Command in command-line:

Linux who, w and whoami Command 1617497346 853 Linux who w and whoami Command

(In my case, there’s no dead process).

To get the current run level of the system, run the “who” command with the “-r” option in the terminal:

Linux who, w and whoami Command 1617497347 969 Linux who w and whoami Command

The -q option is used to display the count of currently logged-in users with the user name. To check it, type:

Linux who, w and whoami Command 1617497348 207 Linux who w and whoami Command

w Command

Run w command in terminal and get the list of users with activities. To display the output, use:

Linux who, w and whoami Command 1617497348 738 Linux who w and whoami Command

First-line displays the following output:

16:36:03 – the current time of the system

up 43 min – System’s uptime

1 user – Number of active users

0.17, 0.14, 0.05 It displays the system load in which many tasks are running or waiting for disk I/O

Second-line displays:

USER – Name of active users

TTY – Terminal name

FROM – Hostname

[email protected] – Logged-in time

IDLE – User interaction time with terminal

JCPU – Time taken to attached processes with TTY

PCPU – Current process time used by the user

WHAT – The current process of user and arguments

whoami Command

Type the “whoami” command in the terminal to get the name of the user’s identity:

Linux who, w and whoami Command 1617497349 205 Linux who w and whoami Command

whoami command has two flags:

  1. Help (–help)
  2. Version (–version)

1. Help
Help command in “whoami” displays help message and then exit it. So, type the following command in the terminal:

Linux who, w and whoami Command 1617497349 197 Linux who w and whoami Command

2. Version
Version command displays the version information of “whoami” and then exit.

Run the given command to check how it works:

Linux who, w and whoami Command 1617497350 682 Linux who w and whoami Command

Conclusion

The guide has shown a detailed note on who, w, and whoami commands.

The who command gives you information about which user is logged in to the system. We have seen how the w command works as it displays users’ details along with activities. Finally, we have checked the working of the whoami Command used to display the user’s identity.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More