Mastering the Linux who Command: User Sessions and Boot Times

Overview

Auditing active terminal sessions and inspecting machine uptime represent fundamental responsibilities in Linux systems administration. This walkthrough provides practical demonstrations of the who utility, exploring column formatting, boot verification, runlevel tracking, and production-ready diagnostic flags.

1. Running the Standard who Utility and Analyzing Column Headers

Invoking who without flags queries the local login records (/var/run/utmp) to display active terminal attachments, logged-in user accounts, and initial connection timestamps.
When the utility produces no stdout stream, the host currently lacks active, interactive login instances.
⚙️ [Essential Flags Reference]

-H : Prepends descriptive column headers (NAME, LINE, TIME, etc.) directly above the data grid.
-b : Reports the precise calendar date and timestamp when the operating system was last rebooted.
-r : Exposes the current operating target or traditional SysV runlevel state.
-u : Appends session activity metrics, including session idle duration and active process identifiers (PID).
-q : Operates as a quick tally, returning user handles alongside an aggregate user head count.
-a : Operates in verbose mode, merging all available session flags and internal system statuses into one unified report.

Executing standard who

Pairing the command with -H forces the terminal to print tabular column labels, vastly simplifying output parsing.
This output layout clarifies the data arrangement across four distinct fields: user account (NAME), assigned TTY/PTS device (LINE), session start timestamp (TIME), and the remote origin or IP address (COMMENT).

Displaying output headers with who -H

2. Inspecting Self-Session Details and Retrieving Quick User Counts

The syntax who am i isolates the execution context strictly to the terminal device bound to the current standard input stream, omitting external peer logins.
If your command environment runs within an automated non-login shell or specific virtual pseudo-terminals unlinked to utmp, the tool returns zero text.

Session verification using who am i

Similarly, running who -m matches the behavior of who am i by focusing exclusively on the calling PTS or TTY endpoint.
In non-interactive shells or containerized execution pipelines that bypass standard login routines, no session record matches the query.

Filtering current terminal session with who -m

Switching to who -q triggers a concise head-count lookup, summarizing all logged-in usernames alongside a system-wide count.
In the terminal capture below, # users=0 confirms that no interactive user accounts maintain open logins on the server at this time.

Counting total accounts with who -q

3. Detecting Operating System Boot Timestamps and Execution Levels

Passing -b isolates the operating system’s latest startup time without having to sift through general session clutter.
Reading system boot 2026-11-17 16:51 allows administrators to pinpoint the exact moment services were initialized after the last restart.

Checking kernel boot time with who -b

With who -r, you can instantly determine the active target state or systemd equivalent runlevel.
The resulting run-level 5 string indicates that the platform operates within a multi-user graphical desktop environment with full networking support.

Retrieving active runlevel with who -r

Utilizing who -u supplements user tracking by detailing idle intervals alongside session-controlling process identifiers (PID).
A completely blank response confirms that the server has no open terminal sessions generating activity or accumulating idle metrics.

Inspecting idle time and process IDs via who -u

4. Comprehensive State Audits and Adjacent Tools (w, whoami)

Executing who -a aggregates all diagnostic routines into a single diagnostic feed, presenting initialization times, runlevels, dead processes, and system clock adjustments.
The execution logs confirm key infrastructure parameters at a glance, highlighting the machine’s boot mark (system boot 2026-11-17 16:51) alongside the GUI state (run-level 5).

Comprehensive diagnostic reporting with who -a

When you simply need to verify the effective user context handling your active shell environment, turn to whoami.
Here, receiving root confirms that the current shell runs with unconstrained superuser administration capabilities.

Confirming active identity via whoami

To access a broader operational view, the companion command w merges user auditing with overall host health metrics, load averages, and foreground processes.
The top status banner denotes that the machine has stayed online for over 28 continuous days without current user presence (0 user), while the table columns (WHAT) track active programs per session.

System health and activity overview with w

Mastering the capabilities of who and its companion tools gives you a lightweight, reliable approach to auditing active connections, session durations, and server initialization states. Incorporating these commands into your standard administration toolkit will streamline access monitoring and enhance overall Linux infrastructure management.