w-Command Explained

w-Command Explained

by -
0 740

The w is an good command which tell us status of Users logged in,What they are doing,CPU stats.

The w command is like who command but showing some extra output i.e.

  • Who is doing what
  • CPU stats

[root@localhost ~]# w
22:08:03 up 38 min,  4 users,  load average: 0.00, 0.20, 0.30                <——— cpu stats
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     –                21:30   37:36   0.03s  0.03s -bash
root     pts/0    192.168.0.155    21:31    0.00s  0.12s  0.04s w
root     pts/1    192.168.0.155    22:05   45.00s  0.05s  0.02s -bash
vikas    pts/2    192.168.0.155    22:07    6.00s  0.02s  0.00s watch df -H
[root@localhost ~]#

where ..

22:08:03 up 38 min,  4 users,  load average: 0.00, 0.20, 0.30

look at first line

Column 1:   Present time on the system.
Column 2:  Up time, here in the above example it is up for 38 minutes.
Column 3:  There are total 4 users logged in.
Column 4:  Load average of your CPU’s. This progressive load average of 1 minute (0.00), 5 minutes back(0.20) and 15 minutes back(0.30). The load average is less than 1 is considered good.

look at next output

vikas     pts/2     192.168.0.155    22:07    6.00s    0.02s    0.00s   watch df -H

where ..

Column 1:  User who logged in. The w command will not show switch user names. The above one’s are real user logins. (vikas )
Column 2:  To which terminal they logged in. (pts/2 )
Column 3:  From which machine they logged in. (192.168.0.155)
Column 4:  At what time they logged in.( 22:07)
Column 5:  From what time they are idle. ( 6.00s)
Column 6:  JCPU, is total  CPU time used by user from login.( 0.02s)
Column 7:  PCPU, CPU time of the currently running process. So PCPU is always smaller than JCPU. ( 0.00s)
Column 8:  Gives details what command/application user is using. ( watch df -H )

Examples:

Find location of user, from where they logged in ?

[root@localhost ~]# w vikas
22:25:31 up 55 min,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
vikas    pts/2    192.168.0.155    22:07   17:34   1.38s  1.36s watch df -H
[root@localhost ~]#

user vikas logged in from IP Address 192.168.0.155

Show in short

[root@localhost ~]# w -s
22:28:26 up 58 min,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM               IDLE WHAT
root     tty1     –                57:59  -bash
root     pts/0    192.168.0.155     0.00s w -s
vikas    pts/2    192.168.0.155    20:29  watch df -H
[root@localhost ~]#

output appeared without JCPU   PCPU

Skip header

[root@localhost ~]# w -h
root     tty1     –                21:30    1:00m  0.03s  0.03s -bash
root     pts/0    192.168.0.155    21:31    0.00s  0.09s  0.00s w -h
vikas    pts/2    192.168.0.155    22:07   22:47   1.79s  1.77s watch df -H
[root@localhost ~]#

CPU stats not shown here.

Other options

[root@localhost ~]# w –help
w: invalid option — ‘-‘
usage: w -hlsufV [user]
-h    skip header
-l    long listing (default)
-s    short listing
-u    ignore uid of processes
-f    toggle FROM field (default on)
-V    display version
[root@localhost ~]#

 

“we are born Free, no Gates or Windows can snatch our Freedom”

use LINUX …it Works  !!!

 

CEO, KV IT-Solutions Pvt. Ltd. | vikas@kvit.in | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry

” We are born free, No Gate and Windows can snatch our freedom “

Download PDF

SIMILAR ARTICLES

0 1123

0 789

NO COMMENTS

Leave a Reply

Required Captcha *