Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

W Command in Linux - DesignLinux

Sep 14 2020
designlinux 0 Comments
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.

Related

Tags: terminal, w

How to Check Java Version on Linux System

Prev Post

How to Install Yii PHP Framework on Ubuntu

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 44
  • 605,794

DesignLinux.com © All rights reserved

Go to mobile version