Home > Environment & Utility > who

Guide to the 'who' Command: Check Current Logged-in Users

`who` command is used to display information about users currently logged into the system on Linux and Unix-like operating systems. It allows you to quickly check which users are logged in, through which terminals, and since when, making it a fundamental tool for system administration and monitoring. Learn how to use the `who` command and its main options through this guide.

Overview of 'who'

`who` command shows the currently active login sessions based on the information recorded in the system's `/var/run/utmp` (or `/var/log/wtmp`) file. This file stores information such as user login and logout records, system boot/shutdown times. `who` is essential for determining who is currently logged into the system, especially in a multi-user environment.

Main Roles of 'who'

`who` command is primarily used for the following purposes:

Main Use Cases

  • Check Logged-in Users: Displays the names, terminals, and login times of all users currently logged into the system.
  • System Monitoring: Monitors for unnecessary or abnormal logins on the server.
  • Collaborative Environment: Checks if other users are logged into the system to facilitate collaboration or avoid conflicts.
  • Script Automation: Used in logic to check if a specific user is logged in via the `who` command.

`who` vs `w` vs `whoami`

There are several commands related to user information, each serving different purposes.

  • `who`: Displays information about 'all' users currently logged into the system.
  • `w`: Shows detailed information about what each logged-in user is 'doing' (currently running processes) along with their login information. Provides more information than `who`.
  • `whoami`: Displays the effective username of 'yourself' executing the current command. (i.e., the logged-in username)

Main Options for the 'who' Command

`who` command can be used without options by default, but it offers useful options to add specific information or change the output format.

1. Basic Information Output

2. Additional Information Output

3. Concise Output

Generated command:

Try combining the commands.

Description:

`who` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn how to effectively check the information of logged-in users through various usage examples of the `who` command.

Check Current Logged-in User List

who

The most basic execution of the `who` command, showing the names, terminals, and login times of all users logged into the system.

Display Column Headers with Logged-in User Information

who -H

Includes headers for each piece of information in the output results (USER, LINE, WHEN, etc.) to enhance readability.

Check Boot Time of the System

who -b

Outputs the exact date and time the system was last booted.

Check Logged-in User Count Briefly

who -q

Displays only the total number of logged-in users and the list of usernames currently logged in briefly.

Check Logged-in Users and Idle Time, PID

who -u

Additionally displays the idle time (inactive time) of each logged-in user and the process ID (PID) controlling the login session.

Check Current Run Level

who -r

Checks the current 'run level' of the system (multi-user mode, single-user mode, etc.).


Same category commands