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.
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
The first line shows the same information as the uptime command:
wThe table columns describe each logged-in session:
| Column | Meaning |
|---|---|
| USER | Logged-in username |
| TTY | Terminal name (tty = physical; pts = SSH or terminal emulator) |
| FROM | Hostname or IP address the user connected from |
| LOGIN@ | Time the user logged in |
| IDLE | Time since the user last pressed a key on the terminal |
| JCPU | CPU time used by ALL processes attached to this tty, including background jobs |
| PCPU | CPU time used only by the current process shown in WHAT |
| WHAT | The 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.
| Option | Effect |
|---|---|
-h | Suppress the header; output only user rows. Useful when piping to awk or grep in scripts |
-f | Toggle the FROM field; visibility varies by distro build |
-i | Show IP address in FROM instead of resolved hostname |
-s | Short format: removes LOGIN@, JCPU, and PCPU columns |
-o | Old-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.
The id command prints user and group identity for any account on the system. It shows the…
sed processes input line by line, applies your commands, and writes the result to standard output.…
Linux provides two main tools for renaming directories: mv for single renames and the rename utility for batch pattern-based…
The sysctl command reads and modifies Linux kernel parameters from the command line. Changes take effect immediately…
The whereis command locates the binary, source, and manual page files for a given command. Unlike which, it…
git clone copies an existing Git repository into a new directory on your local machine. It…