Skip to content

who command in Linux

The who command in Linux is used to display information about currently logged-in users on a Unix system. It shows the username, terminal, and time when the user logged in. Additionally, it can display the host from which the user is logged in. This command can be useful for system administrators to monitor user activity and manage resource allocation on the system.

who Syntax:

Terminal window
who [option] [file]

Linux who Options:

OptionDescription
-bTime of last system boot
-dDead processes
-HDisplay column headers
-lTime of last login
-qList all login names
-uList all processes started by any user

who Parameters:

ParameterDescription
fileShow information on a specific file or terminal

How to use who command:

Display currently logged in users

Terminal window
who

This command will display a list of users who are currently logged into the system.

Display only the usernames of the logged in users

Terminal window
who -q

Using the -q option will show only the usernames of the logged in users.

Display all information about the logged in users with headings

Terminal window
who -H

The -H option displays all information about the logged in users along with headings.

Display the time the system was last booted

Terminal window
who -b

By using the -b option, you can see the time when the system was last booted.

Display a list of currently logged in users and their IP addresses

Terminal window
who -u

Using the -u option will show a list of currently logged in users along with their IP addresses.

Show the pid and time each user has been idle

Terminal window
who -u -p

By using both -u and -p options, you can see the process ID and the time each user has been idle.

Display only the line of information including the current user

Terminal window
who am i

This command will display only the user’s current session information.

Show only the login and logout time for the current user

Terminal window
who -u am I

Using -u on the user “am I” will display the login and logout time for the current user.

How do I use who in Linux?

To use the who command in Linux, execute the following command:

Terminal window
who

What is the output of the who command?

The who command displays information about users who are currently logged into the system, as well as their login names, terminal line numbers, login times, and more.

Terminal window
who

How can I display only the username and terminal of logged-in users?

You can use the who command with the -q or --query option to display only the username and terminal of logged-in users.

Terminal window
who -q

How do I display the time of last system boot using who?

You can use the who command with the -b or --boot option to display the time of the last system boot.

Terminal window
who -b

Can I get the run level of the system with who?

Yes, you can use the who command with the -r or --runlevel option to display the current and previous run levels of the system.

Terminal window
who -r

How can I show the dead processes with who?

You can use the who command with the -d or --dead option to display dead processes that are not properly removed from the UTMP file.

Terminal window
who -d

How can I display the hostname of the system using who?

To display the hostname of the system along with user information, you can use the who command with the -m or --mesg option.

Terminal window
who -m

Can I see all login processes with who?

Yes, you can use the who command with the -p or --processes option to show all login processes along with other information.

Terminal window
who -p

How do I show only the count of logged-in users with who?

To display only the count of logged-in users, you can use the who command with the -q option followed by the --count option.

Terminal window
who -q --count

Applications of the who command

  • Display information about who is logged on
  • Show the username, terminal, login time, and IP address of each user
  • Display idle time and system boot time for each user
  • Check for multiple logins by the same user
  • Monitor and track user activity and login sessions