Lesson 60: w Command
In this lesson, you'll learn how to use the w command to display who is currently logged into your Linux system and what they are doing including session details, system load, and active processes.
The w command is one of the fastest ways to get a real-time snapshot of user activity on a Linux system.
It combines information from /var/run/utmp (active sessions) and /proc (process data) to show you not just who is logged in, but how long they have been idle, what command they are running, and how much CPU their session is consuming.
On shared servers and production systems, w is often the first command a sysadmin runs to understand what is happening.
Syntax
w [OPTIONS] [USER]
If a username is specified, w shows only that user's active sessions.
Options
| Option | Description |
|---|---|
-h |
Suppress the header line |
-s |
Short format β omit JCPU and PCPU columns |
-f |
Toggle the FROM field (remote host) on or off |
-i |
Display IP address instead of hostname in the FROM field |
-V |
Display version information and exit |
Understanding the w Command Output
Before diving into examples, it helps to know what each column means. Running w produces two sections: a system summary line and a per-user table.
w
18:11:29 up 1:21, 1 user, load average: 0.42, 0.29, 0.29
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ravi tty2 tty2 09:45 3.00s 0.13s 0.10s bash
ubuntu pts/0 192.168.1.105 17:55 2min 0.05s 0.01s vim /etc/nginx/nginx.conf
System summary line:
| Field | What It Means |
|---|---|
18:11:29 |
Current system time |
up 1:21 |
System uptime (1 hour, 21 minutes) |
1 user |
Number of users currently logged in |
load average: 0.42, 0.29, 0.29 |
CPU load over the last 1, 5, and 15 minutes |
Per-user columns: