Linux w command tutorial
The Linux w command shows who is logged on in Linux system and what they are doing. Its function is identical to the Linux who command but the w command output provides more detail than who command.
Linux w command syntax
Here is the Linux command syntax:
w -husfVo user |
The '-husfVo' is the w command's options while the 'user' is the username of the Linux user that we want to check.
Here is the meaning of the w command options:
-h skip header
-l long listing (default)
-s short listing
-u ignore uid of processes
-f toggle FROM field (default on)
-o old-style output
-V display version
|
Linux w command examples
Now that you already know the Linux w command syntax, it's time to see some real examples on how to run the command in the Linux command line terminal.
Here is the Linux w command example with no option supplied running in Ubuntu desktop command terminal:
kucing@ubuntu-laptop:~$ w
09:15:10 up 43 min, 2 users, load average: 0.74, 0.38, 0.24
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kucing tty7 :0 08:32 43:15m 57.73s 0.18s x-session-manager
kucing pts/0 :0.0 08:48 0.00s 0.24s 0.00s w
|
The following entries are displayed when issuing the Linux w command: USER (login name), TTY (terminal name), FROM (the remote host), LOGIN@ (login time), IDLE (idle time), JCPU, PCPU, and WHAT (the command line of their current process).
The JCPU 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 is the time used by the current process, named in the "WHAT" field.
Here is the Linux w command example with '-h' option supplied running in Ubuntu desktop command terminal:
kucing@ubuntu-laptop:~$ w -h
kucing tty7 :0 08:32 1:13 1:32m 0.18s x-session-manager
kucing pts/0 :0.0 08:48 0.00s 0.26s 0.00s w -h
|
As you can see in the example above, the result of 'w -h' command is the same as w command with no option except that this time there is no header entries including the summary.
Here is the Linux w command example with '-l' option supplied running in Ubuntu desktop command terminal:
kucing@ubuntu-laptop:~$ w -l
09:51:15 up 1:19, 2 users, load average: 0.00, 0.04, 0.08
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kucing tty7 :0 08:32 1:19 1:40m 0.18s x-session-manager
kucing pts/0 :0.0 08:48 0.00s 0.28s 0.00s w
|
The result of 'w -l' command is the exactly the same as the w command without any option. The 'w -l' is used if no option supplied with the Linux w command. That's why there is no '-l' option in the w command manual page.
Here is the Linux w command example with '-s' option supplied running in Ubuntu desktop command terminal:
kucing@ubuntu-laptop:~$ w -s
09:58:25 up 1:26, 2 users, load average: 0.47, 0.40, 0.22
USER TTY FROM IDLE WHAT
kucing tty7 :0 1:26 x-session-manager
kucing pts/0 :0.0 0.00s w -s
|
The command 'w -s' result shows only USER, TTY, FROM, IDLE and WHAT entries.
Here is the Linux w command example with '-u' option supplied running in Ubuntu desktop command terminal. The command 'w -u' suppose to not print the USER entry if we switch user to root and run the command but it does not happens. See example below:
kucing@ubuntu-laptop:~$ sudo su root@ubuntu-laptop:/home/kucing# w -u 10:09:21 up 1:37, 3 users, load average: 0.00, 0.07, 0.11 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty2 - 10:07 2:07m 0.24s 0.02s -bash kucing tty7 :0 08:32 1:37 2:10m 0.18s x-session-manager kucing pts/0 :0.0 08:48 0.00s 0.34s 5.88s gnome-terminal |
Here is the Linux w command example with '-f' option supplied running in Ubuntu desktop command terminal:
kucing@ubuntu-laptop:~$ w -f
10:17:34 up 1:45, 3 users, load average: 0.85, 0.37, 0.19
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root tty2 10:07 10:20m 0.24s 0.02s -bash
kucing tty7 08:32 1:45 2:19m 0.18s x-session-manager
kucing pts/0 08:48 0.00s 0.36s 6.52s gnome-terminal
|
The result shows that the FROM (remote hostname) field is removed from the result when issuing 'w -u' command.
Here is the Linux w command example with '-o' option supplied running in Ubuntu desktop command terminal. Below it is the default w command with no option example so we can compare the results:
kucing@ubuntu-laptop:~$ w -o 10:23:46 up 1:51, 3 users, load average: 0.01, 0.18, 0.17 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty2 - 10:07 16:32m -bash kucing tty7 :0 08:32 1:51 2:28m x-session-manager kucing pts/0 :0.0 08:48 w -o kucing@ubuntu-laptop:~$ w 10:23:58 up 1:52, 3 users, load average: 0.00, 0.18, 0.17 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty2 - 10:07 16:44m 0.24s 0.02s -bash kucing tty7 :0 08:32 1:52 2:28m 0.18s x-session-manager kucing pts/0 :0.0 08:48 0.00s 0.34s 0.00s w |
The result shows the different between 'w -o' command and 'w' command in the JCPU and PCPU fields. The old format prints blank space for idle times less than one minute.
The command 'w -s' result shows only USER, TTY, FROM, IDLE and WHAT entries.
Here is the Linux w command example if we want to check certain user in the Linux system:
kucing@ubuntu-laptop:~$ w root 11:18:42 up 2:46, 3 users, load average: 0.66, 0.22, 0.13 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty2 - 10:07 1:11 0.24s 0.02s -bash kucing@ubuntu-laptop:~$ w kucing 11:19:23 up 2:47, 3 users, load average: 0.78, 0.30, 0.16 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT kucing tty7 :0 08:32 2:47 3:19m 0.18s x-session-manager kucing pts/0 :0.0 08:48 0.00s 0.34s 0.00s w kucing |
Finally, here is the Linux w command with '-V' option which will print the version as in the example below:
kucing@ubuntu-laptop:~$ w -V
procps version 3.2.7
|
That's all.
Back to Other important Linux basic commands main page.
Popular content



Delicious
Digg
StumbleUpon
Propeller
Reddit
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket
Post new comment