In this article we are going to shows how to use w command in Linux Terminal. If you want to learn about w command in Linux with Examples then this post is ideal for you.
The command w
is a command-line utility that is used to prints the information about currently logged in users and what user is currently doing. It is also display the information about your system that how long the system has been running, current time and the system load average.
Linux is an operating system, like Windows OS, iOS, and Mac OS. It is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system).
Linux OS(operating system) is also distributed under an open source license. Open source following these points :
- Freely to run the program, for any purpose.
- Free to study how the program works.
- Freely to re-distribute copies so you can help your friends.
- Free to distribute copies of your modified versions to others.
How to Use w
command in Linux
In the Linux, the basic syntax of the w command is show as below:
w [OPTIONS] [USER]
When you run the w
command without any option then it will print the output as below:
$ w
Output
20:13:07 up 10 days, 08:10, 2 users, load average: 0.08, 0.22, 0.09
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 101.101.10.2 15:59 1.00s 0.02s 0.00s w
studies pts/1 101.101.10.9 16:14 5.00s 0.00s 0.00s bash
Here,
20:13:07
– Current system time.up 10 days, 08:10
– Length of time in which the system has been up.2 users
– The number of logged-in users.load average: 0.08, 0.22, 0.09
– System load averages for the past1
,5
, and15
minutes.USER
– Name of the logged in user.TTY
– Name of the terminal used by the user.FROM
– Display the host name or IP address .LOGIN@
– Time when the user logged in.IDLE
– Time since the user last interacted with the terminal.JCPU
– Shows the time used by all processes attached to the tty.PCPU
– Displaying the time used by the user’s current process.WHAT
– User’s current process and options/arguments.
If you use one or more user names as arguments with the w
command then the output is restricted to the given users:
$ w studies
Output
20:25:10 up 10 days, 08:25, 2 users, load average: 0.00, 0.05, 0.10
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
studies pts/1 101.101.10.9 16:14 17:35 0.00s 0.00s bash
w Command Options
Use -h
, --no-header
option if you don’t want to print the header in the output:
$ w -h
Outpput
root pts/0 101.101.10.2 15:59 2.00s 0.02s 0.00s w -h
studies pts/1 101.101.10.9 16:14 4.00s 0.00s 0.00s bash
Use the -f
, --from
option to toggles the FROM
field by running below command:
$ w -f
Output
20:30:12 up 10 days, 08:40, 2 users, load average: 0.08, 0.02, 0.00
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 15:59 3.00s 0.02s 0.00s bash
studies pts/1 16:14 7.00s 0.00s 0.00s w -f
Use the -o
, --old-style
option to use the old style output. When you run the w command with this option, the command show blank space when IDLE
, JCPU
, and PCPU
times are less than one minute.
$ w -o
Output
20:37:13 up 10 days, 08:45, 2 users, load average: 0.18, 0.02, 0.03
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 101.101.10.2 15:59 1:37m bash
studies pts/1 101.101.10.9 16:14 w -o
Use -s
, --short
option if you don’t want to print LOGIN@
, JCPU
, and PCPU
fields:
$ w -s
Output
20:40:13 up 10 days, 08:48, 2 users, load average: 0.05, 0.03, 0.00
USER TTY FROM IDLE WHAT
root pts/0 101.101.10.2 2:20 base
studies pts/1 101.101.10.9 3:07 w -s
Use -i
, --ip-addr
option to always show IP address instead of hostname in the FROM
field:
$ w -i
That’s all
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.