How to use w command on linux

The w is a command-line utility shows the information about currently logged in users. It also displays the system information that how long the system has been running, current time and the system load average.
In this article, we will talk about the w command.

How to Use the w Command

The syntax for the w command is as follows:


When w is invoked without any option or argument, the output looks something like this:

15:26:01 up 2 days, 19:21,  1 user,  load average: 1,75, 1,63, 1,42
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
lintut    tty7     :0               Sun20    2days  1:05m  2.32s mate-session

In the output, first line shows the information same as the uptime command. Following information are available in that line:

In the second line following fields are included:

The command then lists all currently logged in users and the information associated with them.
If you pass one or more user names as arguments to the w command, the output is restricted to the given users.

w Command Options

You also can pass the options along with the w command. If you don’t want to print the header you can use -h, --no-header option:

w -h

It will show the only information about the logged in users:

lintut    tty7     :0               Sun20    2days  1:06m  2.34s mate-session

The -f, --from option toggles the FROM field. Whether this filed is shown or hidden by default depend on the distribution you’re using

$ w -f
15:37:42 up 2 days, 19:33,  1 user,  load average: 0,75, 1,34, 1,37
lintut    tty7      Sun20    2days  1:06m  2.35s mate-session

To view output in old style you can use the -o, –-old-style option. If you use this option, the command prints blank space when IDLE, JCPU, and PCPU times are less than one minute.

$ w -o
The -s, --short option tells w to use the short style output. When this option is used, the LOGIN@, JCPU, and PCPU fields are not printed.
$ w -s
To show the IP address instead of the host in the FROM field, you should use the -i, –ip-addr option.
$ w -i


w is a combination from who command and uptime command. Basically, w give us an uptime output, and user logged in information. This two information is always needed by a system administrator to monitor his / her server. w also built-in in every Linux distribution.
If you have any questions, please leave a comment below.

Exit mobile version