who Command in Linux: Explanation with Examples

2 min

Here’s a beginner’s guide on understanding who command in Linux with several examples.

This article is part of the Linux command learning series.

who command

The “who” command in Linux is used to display information about users who are currently logged in to the system. It shows the user’s login name, the terminal from which the user is logged in, the time at which the user logged in, and the remote hostname (if applicable).


Here is the basic syntax for the “who” command:

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

Example of various who command and switches

By default, “who” reads the file /var/run/utmp, which contains information about users who are currently logged in. If no options are specified, it displays each user’s login name, terminal, and time of login.


It gives the following output. As you can see it shows the login name=debugpoint, terminal id tty2 and the date and time of the login.

debugpoint tty2 2023-01-01 11:22 (tty2)
who command - default example
who command – default example

However, if you run the above command in a guest virtual machine, you should see the same but the terminal id would be the x11 server display name i.e. :0.

❯ who
debugpoint :0 2023-01-01 23:36 (:0)

To show the username of the current user and information, use below:


View the last system boot time using the -b option:

❯ who -b
system boot 2023-01-01 23:36

Display the count of users logged in the current system:

❯ who -q

All the above command when paired with -H option, you get a better info with a header line, like below:

who -H

debugpoint tty2 2023-01-01 11:22 (tty2)

If you want to display all the information related to who command in Linux, use the option -a:

who -aH

system boot 2023-01-01 11:19
run-level 5 2023-01-01 11:19
debugpoint + tty2 2023-01-01 11:22 13:26 2042 (tty2)

As always, you can save the output of the who command to any file using the redirect as below:

who > user_details.txt

Example summary of who command options

Here are some who command examples and their explanation:

Here are some options that can be used with the “who” command:

  • -a: Display the hostname, time of login, and processes for each user
  • -b: Display the time of the last system boot
  • -d: Display dead processes (processes that have terminated but have not been removed from the utmp file)
  • -H: Display a header line
  • -l: Display login processes in long format
  • -m: Display only the name and line of the user who is logged in on the terminal specified by ARG1 ARG2
  • -q: Display a count of logged in users
  • -u: Display information about users who have processes that are not detached
  • -w: Display information about users who are logged in, in the same format as the utmp file

Closing Notes

I hope this article helps you to understand who command and its basics. You can also read the who man pages to learn more. Let me know if you have any questions.

This article is part of the Linux command learning series.


Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments