I am a new Linux and Unix system user. How do I list current users and find out what they’re doing on Linux or Unix-like operating system using shell prompt?
The w command displays a list of all logged in to the server and what they are doing. This command is similar to who command, but ends up displaying more information about logged in users.[donotprint]
w command details | |
---|---|
Description | Who is on system and what they're doing |
Category | N/A |
Difficulty | Easy |
Root privileges | No |
Estimated completion time | 5m |
Purpose
Display who is logged into the Linux/Unix server and what they are doing at command execution time.
Syntax
The basic syntax is as follows:
w
w [UserNameHere]
w [UserNameHere1] [UserNameHere2]
w [options]
w [options] [UserNameHere]
Understanding w command output / header
The w command shows the following information about each user and their process on the system:
- USER – User name.
- TTY – Terminal type such as pts/0 or console.
- FROM – The remote host name or IP address.
- LOGIN@ – Login time.
- IDLE – Idel time.
- JCPU – The JCPU time is the time used by all processes attached to the tty.
- PCPU – The PCPU time is the time used by the current process displayed in WHAT field.
- WHAT – The command line of USER’s current process.
w command examples
To see who is currently logged in and what they are doing on your Linux/Unix-based server, type:
$ w
Sample outputs:
The first line of output in this example, displays the current time of day, how long the system has been running, the number of users logged into the system, and the load averages.
Hide the header
To suppress the heading pass the -h option:
$ w
Sample outputs:
vivek pts/0 192.168.1.6 14:10 3:24m 2.15s 0.00s dbus-launch --auto root pts/1 192.168.1.6 14:51 1:41m 0.16s 0.00s pager -s nixcraft pts/2 192.168.1.6 14:52 13:07 0.41s 0.02s vi /etc/passwd root pts/3 192.168.1.6 17:21 3.00s 0.12s 0.01s w -h
Ignore usernames
$ w -u
Use short output format
To hide the login time, JCPU or PCPU times:
$ w -s
Sample outputs:
17:42:36 up 3:36, 4 users, load average: 0.00, 0.01, 0.05 USER TTY FROM IDLE WHAT vivek pts/0 192.168.1.6 3:31m dbus-launch --autolaunch 9ee90112ba2cb root pts/1 192.168.1.6 1:48m pager -s nixcraft pts/2 192.168.1.6 20:12 vi /etc/passwd root pts/3 192.168.1.6 4.00s w -s
Hide/show the FROM field
Toggle printing the from (remote hostname) field. The default as released is for the from field to not be printed:
$ w -f
How do I show information about the specified user only?
To see information about user named ‘vivek’, type:
$ w vivek
Sample outputs:
17:40:02 up 3:34, 4 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT vivek pts/0 192.168.1.6 14:10 3:29m 2.15s 0.00s dbus-launch --auto
w command options
Option | Description |
-h | Do not print header |
-u | Ignore current process username |
-s | Short format |
-f | Show remote hostname field |
-o | Old style output |
--help | Display this help and exit |
-V | Output version information and exit |
Related media
This tutorials is also available in a quick video format:
See also
- w(1) Linux/Unix command man page
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 2 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hello Sir,
Can u please help me decode what does this mean in W cmd’s output
From :5 (I dont see ipaddress here.)
get ssh to your system and then try “w”