Linux system administrators often need access to information about currently logged-in users. The GNU coreutils package features the
who command that provides the necessary options.
In this tutorial, you will learn how to use the
who command to display a list of the logged-in users, see boot-time information, processes, and more.
- A system running Linux
- Access to the command line
Linux who Command Syntax
The syntax for the
who command is:
who [options] [filename]
If you do not specify a file after the command and the options,
who looks for the user information in
/var/run/utmp. This file is the default location for storing data on user logins in Linux.
who Command Examples
The sections below list the
who command options, along with some examples.
Display Account Information
If you use
who without options, it displays a list of the logged-in user names.
Achieve the same effect with the
Note: Some large Linux systems have more active users than the terminal can display on one screen. Pipe
who to the
more command by typing
who | more for a tidy page-by-page look.
Print the Column Headers
--heading) option to display column names above the list of users:
Display Only the Hostname and the User Associated with stdin
To display the information about the current user only, use the
-m flag or add any two arguments to the
who am I is a popular example, but any two words produce the same result.
Show Available Terminals
For a list of available terminals, use the
Display the Time of the Last System Boot
who command shows the last system boot time when used with the
Display All Login Names and Number of Users Logged On
To list the usernames and the number of users currently logged on the system, add the
Add User’s Message Status
Show the user’s message status with the
-T option to check the permissions for writing messages to your terminal. Alternatively, use
--mesg to achieve the same result:
Possible message statuses are:
+– The user has permissions to write to the terminal.
-– The user does not have permissions to write to the terminal.
?– Unable to find the terminal device.
Print Active Processes Spawned by Init
who to display a list of active processes spawned by init, the daemon that starts during the boot process.
To achieve this, add the
Print Dead Processes
For a list of dead processes, use the
If there are dead processes, the terminal prints an output similar to this:
[email protected]:~$ who -d pts/3 2021-01-13 20:22 37405 id=ts/3 term=0 exit=0 pts/4 2021-01-17 10:55 67165 id=ts/4 term=0 exit=04
Display Current Runlevel
For printing the current runlevel of the system, use
Display Last System Clock Change
--time) option prints the last time the system clock was changed:
Show Idle Time
-u option (
--users) shows how long each of the users has been idle:
Force who to Print All Information
who command with the
--all) option to print an output containing the info provided by the
-a flag is convenient when you do not want to use separate options to print different data.
After following this tutorial, you should know how to use the
who command and its options to list only the logged-in users on a Linux system.
Refer to How to List Users in Linux for information on how to list all users.