w Command in Linux

This tutorial explains Linux “w” command, options and its usage with examples.

This command shows who is logged on and what they are doing.

Description:

w displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU, PCPU, and the command line of their current process.

The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.

The PCPU time is the time used by the current process, named in the “what” field.

advertisement
advertisement

Synopsis :
w -[husifV] [user]

Options:

-h
Don’t print the header.
-u
Ignores the username while figuring out the current process and cpu times. To demonstrate this, do a “su” and do a “w” and a “w -u”.
-s
Use the short format. Don’t print the login time,JCPU or PCPU times.
-f
Toggle printing the from (remote hostname) field. The default as released is for the from field to not be printed, although your system administrator or distribution maintainer may have compiled a version in which the from field is shown by default.
-i
Display IP address instead of hostname (if possible)
-V
Display version information.
user
Show information about the specified user only.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

Examples :

$ w
 00:58:14 up 3 min,  2 users,  load average: 0.56, 0.41, 0.18
USER     TTY      FROM       LOGIN@   IDLE   JCPU   PCPU WHAT
username tty7                Sun03   21:09m  4.54s  0.21s gnome-session -
username pts/0    :0         Sun03    0.00s  0.21s  0.00s w
 
$ w -s
 10:16:04 up 13 min,  2 users,  load average: 0.08, 0.15, 0.20
USER     TTY      FROM              IDLE WHAT
mohakkat tty7     :0               11:15m gnome-session --session=ubuntu
mohakkat pts/2    :0               11:14m w -s
 
$ w -h
mohakkat tty7     :0               23:01   11:15m  3.78s  0.19s gnome-session -
mohakkat pts/2    :0               23:01   11:14m  0.08s  0.00s w -h

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.