Linux / Unix: w Command Examples

by on January 27, 2013 · 1 comment· LAST UPDATED January 28, 2014

in , ,

w command

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
DescriptionWho is on system
and what they're doing
Category
Difficulty
Root privilegesNo
Estimated completion time5m
Contents

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:

  1. USER - User name.
  2. TTY - Terminal type such as pts/0 or console.
  3. FROM - The remote host name or IP address.
  4. LOGIN@ - Login time.
  5. IDLE - Idel time.
  6. JCPU - The JCPU time is the time used by all processes attached to the tty.
  7. PCPU - The PCPU time is the time used by the current process displayed in WHAT field.
  8. 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:

Fig. 01: w command in action

Fig. 01: w command in action

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

OptionDescription
-hDo not print header
-uIgnore current process username
-sShort format
-fShow remote hostname field
-oOld style output
--helpDisplay this help and exit
-VOutput version information and exit

Related media

This tutorials is also available in a quick video format:

See also
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdighostip
Processes Managementbgchrootdisownfgjobskillkillallpwdxtimepidofpstree
Searchingwhereiswhich
User Informationgroupsidlastlastcommlognameuserswwhowhoamilidmembers

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 enigma April 7, 2014 at 7:13 am

Hello Sir,
Can u please help me decode what does this mean in W cmd’s output

From :5 (I dont see ipaddress here.)

Reply

Leave a Comment

Tagged as: , ,

Previous Faq:

Next Faq: