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.
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 email@example.com 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?
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 18.104.22.168 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 22.214.171.124 1.00s w -s
Latest posts by Surendra Anne (see all)
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018
- Online training on Linux Bash shell scripting - February 8, 2018