Posted on March 7, 2023 by darshin
In this article, we will talk about the
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
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:
20:36:28 up 20 days, 2:18, 1 user, load average: 0.01, 0.03, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 22.214.171.124 20:15 4.00s 0.08s 0.04s w
The first line provides the same information as the
uptime command. It contains the following columns:
20:36:28– The current system time.
up 20 days– The length of time the system has been up.
1 users– The number of logged-in users.
0.01, 0.03, 0.05– The system load averages for the past 1, 5, 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.
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– 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:
20:41:58 up 20 days, 2:23, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHA
w pulls information about the logged in users from the
w Command Options
w accepts several options that are rarely used.
--no-header option tells
w not to print the header:
Only the information about the logged in users is printed:
root pts/0 126.96.36.199 20:15 0.00s 0.04s 0.00s w -h
--from option toggles the
FROM field. Whether this filed is shown or hidden by default depend on the distribution you’re using
20:42:47 up 20 days, 2:24, 1 user, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 20:15 7.00s 0.04s 0.00s w -f
--old-style option, tells
w to use the old style output. When this option is used, the command prints blank space when
PCPU times are less than one minute.
20:43:11 up 20 days, 2:25, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 188.8.131.52 20:15 w -o
--short option tells
w to use the short style output. When this option is used, the
PCPU fields are not printed.
22:51:48 up 12 days, 11:18, 2 users, load average: 0.04, 0.03, 0.00 20:44:11 up 20 days, 2:26, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM IDLE WHAT root pts/0 184.108.40.206 3.00s w -s
--ip-addr option forces
w to always show IP address instead of hostname in the
w command prints information about the system’s activity and logged in users. For more information, type
man w in your terminal.
Leave A Comment
What’s happening in your mind about this post !