• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

W Command in Linux

Written by Admin, Updated On September 13, 2020
terminal, w
W Command in 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 guide we will discuss about the w command.

How to Use the w Command#

Below is the basic syntax for the w command:

w [OPTIONS] [USER]

If you run the w command without any option, it will show the output something like below:

11:14:33 up 2 days, 3:55,  1 user,  load average: 0.00, 0.00, 0.00
USER     	TTY      FROM       	   LOGIN@   IDLE   JCPU   PCPU WHAT
tecnstuff   pts/0    102.102.102.127   11:13    0.00s  0.05s  0.00s w
root		pts/0    102.102.102.128   14:08    3.00s  0.04s  0.00s w

In the output, first line shows the information same as the uptime command. Following information are available in that line:

  • 11:14:33 – The current system time.
  • up 2 days, 3:55 – The length of time the system has been up.
  • 1 users – The number of logged-in users.
  • load average: 0.10, 0.08, 0.10 – The system load averages for the past 1, 5, and 15 minutes.

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.

After that it shows the users list which are logged in with the associated informations. If you will pass the user name with as an argument then it will show the information only about that user.

12:09:07 up 2 days, 4:50,  1 user,  load average: 0.00, 0.00, 0.00
USER     	TTY      FROM       	   LOGIN@   IDLE   JCPU   PCPU WHAT
tecnstuff   pts/0    102.102.102.127   12:08    3.00s  0.04s  0.00s w

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:

tecnstuff   pts/0    102.102.102.127   11:13    0.00s  0.05s  0.00s w
root		pts/0    102.102.102.128   14:08    3.00s  0.04s  0.00s w

To toggle the FROM field you should use the -f, --from option.

 12:26:27 up 2 days, 5:07,  1 user,  load average: 0.00, 0.00, 0.00
USER    	TTY       LOGIN@   IDLE   JCPU   PCPU WHAT
tecnstuff   pts/0     12:26    2.00s  0.03s  0.00s w -f

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.

12:27:56 up 2 days, 5:09,  1 user,  load average: 0.00, 0.00, 0.00
USER     	TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
tecnstuff   pts/0    102.102.102.127   12:26                        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
12:33:25 up 2 days,  5:14,  1 user,  load average: 0.00, 0.00, 0.00
USER     	TTY      FROM          	   IDLE   WHAT
tecnstuff   pts/0    102.102.102.127   1.00s 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
12:35:30 up 2 days,  5:16,  1 user,  load average: 0.00, 0.00, 0.00
USER    	TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
tecnstuff   pts/0    102.102.102.127   12:26    1.00s  0.04s  0.00s w -i

Conclusion#

Use w command to get the information about the system’s logged in users and activity. To get mroe information about the w command, you can type man w in your terminal.

If you have any questions, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Check Java Version on Linux System
Next Article   Get CPU Information on Linux Systems

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook