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.
|w command details|
|Description||Who is on system|
and what they're doing
|Estimated completion time||5m|
Display who is logged into the Linux/Unix server and what they are doing at command execution time.
The basic syntax is as follows:
w [UserNameHere1] [UserNameHere2]
w [options] [UserNameHere]
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.
To see who is currently logged in and what they are doing on your Linux/Unix-based server, type:
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.
To suppress the heading pass the -h option:
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
$ w -u
To hide the login time, JCPU or PCPU times:
$ w -s
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
Toggle printing the from (remote hostname) field. The default as released is for the from field to not be printed:
$ w -f
To see information about user named 'vivek', type:
$ w vivek
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
|-h||Do not print header|
|-u||Ignore current process username|
|-f||Show remote hostname field|
|-o||Old style output|
|--help||Display this help and exit|
|-V||Output version information and exit|
This tutorials is also available in a quick video format: