How To Use W Command
In this article, we will talk about the w command.
w is a command-line utility that displays information about currently logged in users and what each user is doing. It also gives information about how long the system has been running, the current time, and the system load average.
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:
The first line provides the same information as the uptime command. It contains the following columns:
18:33:10– The current system time.
up 23 days – The length of time the system has been up.
1 user – The number of logged-in users.
load average: 0.00, 0.01, 0.05 – The system load averages for the past 0, 1, and 5 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.
The second line includes the following fields:
USER – The name of the logged user.
TTY – The name of the terminal used by the user.
FROM – The host name or IP address from where the user is logged in.
LOGIN@ – The time when the user logged in.
IDLE – The time since the user last interacted with the terminal. Idle time.
JCPU – The time used by all processes attached to the tty.
PCPU – The time used by the user’s current process. The one displayed in the WHAT field.
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 pulls information about the logged in users from the /var/run/utmp file.
w Command Options
w accepts several options that are rarely used.
The -h, –no-header option tells w not to print the header:
Only the information about the logged in users is printed:
The -f, –from option toggles the FROM field. Whether this filed is shown or hidden by default depend on the distribution you’re using
The -o, –old-style option, tells w to use the old style output. When this option is used, the command prints blank space when IDLE, JCPU, and PCPU times are less than one minute.
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.
The -i, –ip-addr option forces w to always show IP address instead of hostname in the FROM field.
The w command prints information about the system’s activity and logged in users. For more information, type man w in your terminal.