Administration toolsCommands

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:

  • 15:26:01 – The current system time.
  • up 2 days, 19:21 – The length of time the system has been up.
  • 1 users – The number of logged-in users.
  • load average: 1,75, 1,63, 1,42 – The system load averages for the past 15, and 15 minutes. The system load average is a measurement of the number of jobs that are currently running or waiting for disk I/O. It basically tells you how busy your system has been over the given interval.

In the second line following fields are included:

  • USER – It shows the name of the logged in user.
  • TTY – The name of the terminal used by the user.
  • FROM – Display the host name or IP address from where the user is logged in.
  • LOGIN@ – It’s time when the user logged in.
  • IDLE – The time since the user last interacted with the terminal. Idle time.
  • JCPU – Shows the time used by all processes attached to the tty.
  • PCPU – Displaying the time used by the user’s current process.
  • WHAT – The user’s current process and options/arguments.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button