How To

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.

Cyber Defence

Recent Posts

id Command in Linux: Display User and Group Information

The id command prints user and group identity for any account on the system. It shows the…

2 hours ago

sed Delete Lines: Remove Lines by Number, Pattern, or Range

sed processes input line by line, applies your commands, and writes the result to standard output.…

2 hours ago

How to Rename Directories in Linux: mv, Loops, and rename

Linux provides two main tools for renaming directories: mv for single renames and the rename utility for batch pattern-based…

2 hours ago

sysctl Command in Linux: View and Change Kernel Parameters

The sysctl command reads and modifies Linux kernel parameters from the command line. Changes take effect immediately…

1 day ago

whereis Command in Linux: Find Binary, Source, and Man Pages

The whereis command locates the binary, source, and manual page files for a given command. Unlike which, it…

1 day ago

git clone: Clone a Repository from Remote or Local Sources

git clone copies an existing Git repository into a new directory on your local machine. It…

1 day ago