The w is an excellent command which will give you a quick overview of
1) Users logged in.
2) What they are doing.
3) CPU stats.

w command is similar to who command with bit of variation. The who command will not give information about what application/command an user is running right now and no CPU stats as well. This will make w command more powerful when compared to who command.

In this post we will see how to use w in an effective way to know about system performance and what is happening on the system.

Example 1: Get an overview of what is happening at system.

root@linuxnix:/home/surendra# w
 19:32:37 up 1 day, 4:38, 5 users, load average: 0.30, 0.31, 0.36
 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
 root tty1 19:27 5:28 0.03s 0.02s -bash
 surendra :0 :0 Sun14 ?xdm? 2:37m 2.95s init --user
 surendra pts/12 :0 Sun14 1.00s 0.26s 1:53 gnome-terminal
 surendra pts/27 :0 11:33 6:36 0.10s 0.03s ssh root@red1.taggle.com.au
 surendra pts/28 :0 15:55 6:33 0.22s 1:53 gnome-terminal

If we decode first line that will translate in to.

19:32:37 up 1 day, 4:38, 5 users, load average: 0.30, 0.31, 0.36

Column 1: Present time on the system.
Column 2: Up time, here in the above example it is up for 1 day and 4.38 hours.
Column 3: There are total 5 users logged in.
Column 4: Load average of your CPU’s. This progressive load average of 1 minute (0.30), 5 minutes back(0.31) and 15 minutes back(0.36). If the load average is less than 1, that is always good.

Now next lines indicates below information.

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

Example 2: How to know about a user where they logged in?

w username

Example:

root@linuxnix:/home/surendra# w surendra
19:57:01 up 1 day, 5:03, 5 users, load average: 0.05, 0.24, 0.26
 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
 surendra :0 :0 Sun14 ?xdm? 2:40m 2.97s init --user
 surendra pts/12 :0 Sun14 0.00s 0.27s 1:54 gnome-terminal
 surendra pts/27 :0 11:33 31:00 0.07s 0.07s bash
 surendra pts/28 :0 15:55 30:57 0.18s 1:54 gnome-terminal

Example 3: Print from which IP address users logged in instead of host names.

root@linuxnix:~# w -i
03:58:14 up 163 days, 5:46, 2 users, load average: 0.19, 0.15, 0.14
 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
 root tty1 17Sep15 143days 0.37s 0.31s -bash
 root pts/0 1.144.96.147 03:58 3.00s 0.05s 0.00s w -i

Example 4: Just show a shorter form w, without JCPU, PCPU etc.

root@linuxnix:~# w -s
04:00:23 up 163 days, 5:48, 2 users, load average: 0.23, 0.16, 0.14
 USER TTY FROM IDLE WHAT
 root tty1 143days -bash
 root pts/0 1.144.96.147 1.00s w -s
The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.