Check Linux Logged-in Users and Server Load at a Glance! Practical Guide to the w Command

Overview

In server monitoring and user session management, the w command is an essential tool for immediately understanding currently logged-in users and system load (Load Average). In this article, we will examine everything step by step, from interpreting the basic output of the w command to frequently used option combinations in practice and the differences between who and uptime.

1. Checking Active Users and System Load at a Glance: Basic w Execution

Run the uptime command to compare and check the system uptime and load information, which matches the first line of the w command output.

uptime

The w command is used to quickly identify users currently logged into the system, the tasks each user is performing, and the system load status.
The first line of output displays the current time, system uptime, number of connected users, and load averages over the last 1, 5, and 15 minutes (Load Average). Starting from the second line, detailed session information for each user is printed.
⚙️ [Key Options]

-h, --no-header : Displays only the user list without printing the header (top load information and field titles).
-s, --short : Changes to a shorter output format, omitting the login time, JCPU, and PCPU fields.
-f, --from : Toggles whether to display the FROM field showing the connection source IP address or hostname.
-i, --ip-addr : Displays the connection source in IP address format instead of hostname.
-o, --old-style : Uses the old-style blank output format, displaying a blank space if idle time is less than one minute.

w

2. Writing Monitoring Scripts by Omitting Headers and Simplifying Output (-h, -s)

The w -h command suppresses the top system uptime summary information and the column header line, outputting only the pure user session list.
It is frequently used in scripts when parsing user counts or specific user information to exclude unnecessary header lines.
Since no users are currently logged into the system, an empty result is returned.

w -h

The w -s command changes the output format to a short summary format.
Because fields included in the default output such as login time (LOGIN@), JCPU, and PCPU are omitted, key information such as session, source, idle time (IDLE), and running command (WHAT) can be verified concisely even in narrow terminal environments.

w -s

The w -hs command combines the option to suppress the top header summary (-h) with the simplified output option (-s).
By removing both headers and unneeded fields, you can immediately retrieve only the core session data lines, making it extremely useful for shell script-based monitoring automation.
Since there are no currently connected users, it terminates without displaying anything.

w -hs

3. Querying Specific Users and Controlling IP Address Display (-i, Specifying User)

For practice with filtering specific users, check the currently logged-in account name using the whoami command and save it to the CURRENT_USER variable.

CURRENT_USER=$(whoami)

The w "$CURRENT_USER" command selectively displays only the connection session information of the specified user account.
This is useful in multi-user environments with many active connections to quickly track a specific user’s activity or idle time.

w “$CURRENT_USER”

The w -i command fixes the output format of the connection location (FROM) to an IP address instead of a hostname.
This is utilized when you need to avoid delays caused by reverse DNS lookups and verify exact remote connection IP addresses.

w -i

4. Practical Comparative Analysis: Key Differences Among w vs who vs uptime

The uptime command concisely outputs the system’s current time, uptime, currently connected user count, and load averages over the last 1, 5, and 15 minutes (Load Average) in a single line.
It is useful when you want to quickly check the server’s overall operating status and load indicators without detailed per-user session information.

uptime

The who -u command prints the list of users currently logged into the system along with terminal information, login time, idle time, and process ID (PID).
It is suitable when focusing on identifying active sessions while excluding system load and user-executed command details.
Since no active sessions currently exist, an empty result is printed.

who -u

The w command combines the system load summary of uptime with the logged-in session list of who, comprehensively displaying the task each user is executing (WHAT) and CPU usage.
System load averages are displayed at the top, followed by session list headers below, allowing you to simultaneously compare and analyze server load and user activity on a single screen.

w

So far, we have explored how to check and analyze Linux logged-in users and server load status at a glance using the w command.
Try utilizing this as part of your standard routine during server inspections or troubleshooting in real-world operations.