The w command in Linux is a core system administration utility that displays real-time information about currently logged-in users and active system processes. First introduced in 1 BSD Unix in 1977 by William Joy, the command extracts runtime telemetry from the system file /var/run/utmp and the Linux virtual filesystem (/proc) to report system uptime, load averages, user login sessions, and active CPU usage. System administrators rely on w as a lightweight diagnostic tool to audit server access, monitor resource allocation, and identify unresponsive interactive sessions across multi-user Unix-like environments.
When executed in a shell terminal, the w command performs two primary diagnostic tasks in sequence. First, it generates a single-line system header identical to the output of the uptime utility. This header specifies the current server system time, the duration of time the operating system has run continuously since its last reboot, the total count of currently logged-in user accounts, and three system load average numbers. These load averages measure computational demand across the preceding 1-minute, 5-minute, and 15-minute intervals, representing the average number of runnable or uninterruptible CPU threads waiting for processing time.
Second, the utility queries kernel memory structures and active terminal device connections to assemble a per-user session summary table. By parsing session records stored in /var/run/utmp (or /run/utmp on modern systemd-based Linux distributions), w maps terminal interfaces to specific local or remote SSH users. It subsequently scans the process file system (/proc) to correlate process identification numbers (PIDs) with the specific terminal session that spawned them.
Executing the standard w command without extra options returns an eight-column output table summarizing user activities and computational workload across all active pseudoterminal (pts) and console (tty) sessions.
| Column Name | Data Type | Description and Operational Definition |
|---|---|---|
USER | String | The account name of the logged-in system user. |
TTY | String | The terminal line name (e.g., tty1 for local physical console or pts/0 for SSH remote connections). |
FROM | Hostname / IP | The remote IP address or DNS hostname from which the user established the session connection. |
LOGIN@ | Timestamp | The exact system time or calendar date when the user authenticated and initiated the terminal session. |
IDLE | Time Duration | The duration of time elapsed since the user last pressed a key or submitted input to the command prompt terminal. |
JCPU | Time Duration | Joint CPU time; the total CPU processing time consumed by all background and foreground processes attached to the terminal session. |
PCPU | Time Duration | Process CPU time; the specific CPU processing time consumed by the currently active process listed under the WHAT field. |
WHAT | Command String | The complete command line string and arguments of the process currently executing in the user session. |
The distinction between JCPU and PCPU is critical for server resource auditing. The JCPU metric accounts for every process executed since the session began, including past completed background jobs, whereas PCPU concentrates strictly on the foreground execution thread currently running in the terminal session.
The modern Linux implementation of w, maintained within the procps-ng user-space package, provides several flags to modify output formatting and refine diagnostic queries:
-h or --no-header: Suppresses the top uptime and load average header line, returning only user session rows for easier script parsing.-s or --short: Displays a condensed output format that omits the LOGIN@, JCPU, and PCPU columns to fit constrained display viewports.-f or --from-line: Toggles the display of the remote host origin column (FROM) on or off.-i or --ip-addr: Forces the utility to display numerical IP addresses rather than attempting reverse DNS hostname lookups, accelerating command output speeds on networks with slow DNS response times.-u or --no-current: Ignores individual process accounting when calculating idle duration and CPU allocation metrics.Administrators can also append a specific target username argument (e.g., w alex) to filter output, restricting the session list exclusively to matching user accounts on heavily populated server environments.
Linux offers several commands for system inspection, but each utility addresses a distinct operational requirement. The table below illustrates how w integrates features from related core commands:
| Command Tool | Primary Function | Data Sources | Output Granularity |
|---|---|---|---|
w | Displays system load, logged-in sessions, idle times, and active command execution. | /var/run/utmp and /proc | Comprehensive (System status + Session telemetry + Process tracking) |
who | Lists active user logins, terminal types, and login timestamps. | /var/run/utmp exclusively | Basic (User session records without process details) |
uptime | Reports system clock time, continuous running time, user count, and load averages. | /proc/uptime and /proc/loadavg | High-level (System load overview only) |
ps | Reports active system processes across daemon services and user sessions. | /proc directory structure | Detailed process level (PIDs, memory usage, execution status) |
Because w unifies header metrics from uptime with session data from who and process attributes from ps, it serves as an efficient single-line command for quick diagnostic triage when accessing an unfamiliar Linux system.
System administrators routinely utilize w during incident response, system performance tuning, and access security audits:
w immediately upon connecting to a server to review the FROM column, verifying that all incoming remote connections originate from authorized IP addresses or internal VPN entry points.w reveals which active user session is running CPU-intensive operations under the WHAT and PCPU fields.IDLE column, administrators can locate abandoned remote SSH connections, gather their terminal device names, and safely terminate dormant background processes to preserve system memory and socket handles.While both commands inspect active system logins, the who command only shows basic session details like username, terminal device, and login timestamp. The w command provides broader insight by combining those login details with overall system uptime, 1/5/15-minute load averages, user idle times, CPU usage metrics (JCPU and PCPU), and the exact active process command line.
The w command calculates idle time by inspecting the file status of the user's assigned terminal character device in /dev (such as /dev/pts/0). It reads the last access and modification times of that specific device node to determine how long it has been since the user last entered input or executed a keyboard action within that terminal session.
The w command retrieves operational data from two main system areas: the /var/run/utmp file (or /run/utmp on systemd distributions), which maintains records of currently logged-in users, and the /proc virtual filesystem. It reads /proc/uptime and /proc/loadavg for system performance metrics and inspects process subdirectories in /proc to correlate processes with active terminal sessions.
You can prevent the w command from hanging on DNS lookups by using the -i or –ip-addr command flag (e.g., w -i). By default, w attempts to resolve remote connection IP addresses into hostnames using reverse DNS, which can cause delays if network DNS servers are slow or unreachable.
Manchester United came from two goals down to beat Roma 3-2 in Tuesday's Champions League…
The useful number from Bayern vs. Atlético Madrid was never the 2-0 on the board;…
A comeback like Tuesday's at Old Trafford buys a manager time, not answers — and…
The win moves the needle on the Manchester United F.C. vs AS Roma standings, but…
Inter's 3-0 win over Feyenoord on Tuesday was a response with a shape to it,…
Kylian Mbappé has become the youngest player to reach 100 Champions League appearances, hitting the…