W Command in Linux

W Command in Linux

All

Linux Articles / All 77 Views comments

On this article, we'll speak concerning the w command.

w is a command-line utility that shows details about at present logged in customers and what every consumer is doing. It additionally provides details about how lengthy the system has been operating, the present time, and the system load common.

Tips on how to Use the w Command

The syntax for the w command is as follows:

w [OPTIONS] [USER]

When w is invoked with none choice or argument, the output seems one thing like this:

 21:41:07 up 12 days, 10:08,  2 customers,  load common: zero.28, zero.20, zero.10
USER      TTY      FROM        LOGIN@   IDLE   JCPU   PCPU WHAT
root      pts/zero    10.10.zero.2   20:59    1.00s  zero.02s  zero.00s w
linuxize  pts/1    10.10.zero.eight   21:41    7.00s  zero.00s  zero.00s bash

The primary line offers the identical info because the uptime command. It accommodates the next columns:

  • 21:41:07- The present system time.
  • up 12 days, 10:08 - The size of time the system has been up.
  • 2 customers - The variety of logged-in customers.
  • load common: zero.28, zero.20, zero.10 - The system load averages for the previous 1, 5, and 15 minutes. The system load common is a measurement of the variety of jobs which are at present operating or ready for disk I/O. It principally tells you ways busy your system has been over the given interval.

The second line consists of the next fields:

  • USER – The identify of the logged consumer.
  • TTY – The identify of the terminal utilized by the consumer.
  • FROM – The host identify or IP tackle from the place the consumer is logged in.
  • LOGIN@ – The time when the consumer logged in.
  • IDLE – The time because the consumer final interacted with the terminal. Idle time.
  • JCPU – The time utilized by all processes hooked up to the tty.
  • PCPU – The time utilized by the consumer's present course of. The one displayed within the WHAT area.
  • WHAT – The consumer's present course of and choices/arguments.

The command then lists all at present logged in customers and the knowledge related to them.

In case you move a number of consumer names as arguments to the w command, the output is restricted to the given customers:

w linuxize
 22:08:55 up 12 days, 10:35,  2 customers,  load common: zero.00, zero.06, zero.12
USER      TTY      FROM        LOGIN@   IDLE   JCPU   PCPU WHAT
linuxize  pts/1    10.10.zero.eight   21:41    27:55   zero.00s  zero.00s bash

w Command Choices

w accepts a number of choices which are not often used.

The -h, --no-header choice tells w to not print the header:

w -h

Solely the details about the logged in customers is printed:

root      pts/zero    10.10.zero.2   20:59    1.00s  zero.02s  zero.00s w -h
linuxize  pts/1    10.10.zero.eight   21:41    7.00s  zero.00s  zero.00s bash

The -f, --from choice toggles the FROM subject. Whether or not this filed is proven or hidden by default depend upon the distribution you are utilizing

w -f
 22:48:39 up 12 days, 11:15,  2 customers,  load common: zero.03, zero.02, zero.00
USER      TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
root      pts/zero     20:59    5.00s  zero.03s  zero.01s bash
linuxize  pts/1     21:41    1.00s  zero.02s  zero.00s w -f

The -o, --old-style choice, tells w to make use of the previous fashion output. When this feature is used, the command prints clean area when IDLE, JCPU, and PCPU occasions are lower than one minute.

w -o
 22:50:33 up 12 days, 11:17,  2 customers,  load common: zero.14, zero.04, zero.01
USER      TTY      FROM        LOGIN@   IDLE   JCPU   PCPU WHAT
root      pts/zero    10.10.zero.2   20:59    1:59m               bash
linuxize  pts/1    10.10.zero.eight   21:41                        w -o

The -s, --short choice tells w to make use of the brief type output. When this feature is used, the LOGIN@, JCPU, and PCPU fields usually are not printed.

w -s
 22:51:48 up 12 days, 11:18,  2 customers,  load common: zero.04, zero.03, zero.00
USER      TTY      FROM         IDLE WHAT
root      pts/zero    10.10.zero.2    three:14  bash
linuxize  pts/1    10.10.zero.eight    2.00s w -s

The -i, --ip-addr choice forces w to all the time present IP tackle as an alternative of hostname within the FROM subject.

w -i

Conclusion

The w command prints details about the system's exercise and logged in customers. For extra info, sort man w in your terminal.

In case you have any query, please depart a remark under.

Comments