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:
$ w [OPTIONS] [USER]
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 [email protected] 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
15minutes. 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.
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.
[email protected]– 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
It will show the only information about the logged in users:
lintut tty7 :0 Sun20 2days 1:06m 2.34s mate-session
--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 USER TTY [email protected] IDLE JCPU PCPU WHAT 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
--shortoption tells w to use the short style output. When this option is used, the [email protected], JCPU, and PCPU fields are not printed.
$ w -s
$ 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.