who command in Linux

who command in Linux

How to use the who command:

The main syntax of the who command is as follows:

who [OPTION]... [ FILE | ARG1 ARG2 ]  

When called without any options or arguments, the output is something like this:

root     pts/0        2020-11-17 20:10 (  shetaban    pts/1        2020-11-17 20:11 (

The who command produces a formatted list of all users currently logged into the system.

Each line consists of four fields separated by one or more spaces:

  • Registered user name
  • User terminal
  • When the user is logged in.
  • The hostname or IP address from where the user logged in. To force Ips, use the –ips option.

If you want to print column headings, add the -H (–heading) option:

who -h


NAME      LINE         TIME             COMMENT  root      pts/0        2020-11-17 20:10 (  linuxize  pts/1        2020-11-17 20:11 (

This command captures information about the system and people logged in from the /var/run/utmp file. If you want to use another file, pass the file path to the command.

The who command accepts two non-optional arguments. When invoked with two arguments, the command prints only information about the terminal associated with the current user. The same output is displayed when using the -m option.

You can use either argument:

who am i  who mom love  who foo bar  who -m

Each of the above commands prints the same information:

shetaban pts/1        2020-11-17 20:11 (  

who command options:

The who command accepts several rarely used options.

The -b, –boot option tells you who last printed the system boot:

         system boot  2020-07-20 19:02  

To get a list of all dead processes, use the -d, –dead option:

who -d

The -r, –runlevel option tells who to show the current level:

who -r


         run-level 5  2020-07-20 19:02  

To get just the username and the number of currently logged in users, use the -q, –count option:

who -q


root shetaban  # users=2

The -a option forces everyone to print all information:

who -a


system boot  2020-07-20 19:02  LOGIN      tty1         2020-07-20 19:02               673 id=tty1             run-level
support hosting100