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

Kali Linux Commands Cheat Sheet: Complete Quick Reference

This cheat sheet covers the essential Kali Linux commands every pentester and ethical hacker uses…

8 hours ago

What I Wish I Knew Before Learning Malware Analysis and Reverse Engineering

When I first started learning malware analysis and reverse engineering, I thought the hardest part…

4 days ago

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

2 weeks ago

git cherry-pick Command: Apply Commits from Another Branch

Sometimes the change you need already exists, just on the wrong branch. A hotfix lands…

2 weeks ago

Best Email APIs for Secure Business Email: Why Developers Are Moving Beyond SMTP

Email is still one of the most important communication channels inside modern applications. Password resets,…

2 weeks ago

Nginx Commands in Linux: Start, Stop, Reload, Test, and Log

Nginx is a high-performance web server and reverse proxy trusted by some of the largest…

3 weeks ago