Cybersecurity Updates & Tools

w Command in Linux: Show Logged-In Users and System Activity

The w command in Linux shows who is currently logged in to the system and what each user is doing. It combines the output of who and uptime into a single view — logged-in users alongside the current time, uptime, and load averages.

How to Use the w Command in Linux

The syntax is:

bashw [OPTIONS] [USER]

Run without arguments to see all logged-in users:

bashw

w reads session data from /var/run/utmp on non-systemd hosts. Pass a username to restrict the output to that user only:

bashw linuxize

Understanding the Output: Header and Columns

The first line shows the same information as the uptime command:

  • Current time – the system clock at the moment you ran w
  • Uptime – how long the system has been running
  • Users – number of currently logged-in users
  • Load average – three numbers for the past 1, 5, and 15 minutes; each represents jobs currently running or waiting for disk I/O; a value higher than your CPU core count means the system is under pressure

The table columns describe each logged-in session:

ColumnMeaning
USERLogged-in username
TTYTerminal name (tty = physical; pts = SSH or terminal emulator)
FROMHostname or IP address the user connected from
LOGIN@Time the user logged in
IDLETime since the user last pressed a key on the terminal
JCPUCPU time used by ALL processes attached to this tty, including background jobs
PCPUCPU time used only by the current process shown in WHAT
WHATThe user’s active process and its arguments

The key distinction: JCPU includes background jobs; PCPU covers only the foreground process. If a user has long-running background processes, JCPU will be noticeably higher than PCPU.

IDLE is useful for spotting sessions that have been left open with no activity for an extended period.

w Command Options

OptionEffect
-hSuppress the header; output only user rows. Useful when piping to awk or grep in scripts
-fToggle the FROM field; visibility varies by distro build
-iShow IP address in FROM instead of resolved hostname
-sShort format: removes LOGIN@, JCPU, and PCPU columns
-oOld-style output: shows blank space for IDLE/JCPU/PCPU values under one minute
bashw -h          # no headerw -i          # IP address instead of hostnamew -s          # short format, fewer columns

Use w for a combined view of active users and system load, w username to check a specific user’s session, and -h when using the output in scripts. Leave a comment below if you run into any issues.