w command in Linux with Examples
Last Updated :
31 Jul, 2023
The 'w' command in Linux gives us important information about who is currently using the computer, how much the computer is being used, and what programs are running. It's a handy tool for people who take care of computer systems, as it helps them keep an eye on what users are doing, how much of the computer's power is being used, and how to make everything run smoothly.
Syntax of `w` command in Linux
w [options] user [...]

The output includes the following columns:
|
Displays the username of the logged-in user.
|
Shows the terminal device associated with the user session.
|
Indicates the remote host or IP address the user is connected to
|
Displays the time at which the user logged in.
|
Shows the duration of inactivity since the user's last interaction.
|
Represents the CPU time used by all processes attached to the user's session.
|
Displays the percentage of CPU time used by the user's current process.
|
WHAT: Provides information about the command or process running in the user's session.
|
Options Available in `w` command in Linux
|
Suppresses the header row from being displayed in the output.
|
Ignores the username when calculating the current process and CPU times.
|
Uses the short format, omitting the login time, JCPU (total CPU time used by all processes), and PCPU (CPU time used by the current process) times.
|
Toggles the printing of the 'from' field (remote hostname). By default, it is not printed, but this option can change that.
|
Displays a help message that provides information about the usage and options of the 'w' command.
|
Displays the IP address instead of the hostname in the 'from' field.
|
Displays version information about the 'w' command.
|
Prints a blank space for idle times that are less than one minute.
|
Shows information about the specified user only.
|
Examples:
w -h: This option doesn't print the header.
w -h
w -u: This option will ignore the username while figuring out the current process and cpu times.
w -u
w -s : This option uses the short format. It will not print the login time, JCPU or PCPU times.
w -s
w -f : This option will toggle printing the from (remote hostname) field. The default as released is from field which not be printed. Although your system administrator or your distribution maintainer may have compiled a version in which the from field is shown by default.
w -f
w --help: This option will display help message and exit.
w --help
w -i : This option will display IP address instead of hostname for from field.
w -i
w -V : This option will display version information.
w -V
w -o : This option will print blank space for idle times less than one minute.
w -o
w user : This option will show information about the specified user only.
w user
Conclusion
In this we discussed about `w` command in Linux w is used for administrators to monitor user activity, manage system resources and optimize performance. It also provides valuable information about logged-in users, system load, and active processes. Overall, we can say that it is an essential utility for efficient system administration in Linux.
Similar Reads
Linux | Uptime command with examples It is used to find out how long the system is active (running). This command returns set of values that involve, the current time, and the amount of time system is in running state, number of users currently logged into, and the load time for the past 1, 5 and 15 minutes respectively. Linux uptime S
5 min read
How to add User in Linux | useradd Command useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the
5 min read
usermod command in Linux with Examples usermod command or modify user is a command in Linux that is used to change the properties of a user in Linux through the command line. After creating a user we have to sometimes change their attributes like password or login directory etc. so in order to do that we use the Usermod command. The info
4 min read
username Command in Linux With Examples Linux as an operating system holds the capabilities of handling multiple users each with a username and a display name (Full Name). So it is important to keep a check on the users and their related information in order to maintain the integrity and security of the system. Whenever a user is added it
4 min read
users command in Linux with Examples users command in Linux system is used to show the user names of users currently logged in to the current host. It will display who is currently logged in according to FILE. If the FILE is not specified, use "/var/run/utmp". "/var/log/wtmp" as FILE is common. Syntaxusers [OPTION]... [FILE]where,OPTIO
2 min read
How to Delete User in Linux | userdel Command Managing user accounts is an essential aspect of Linux system administration. Understanding how to delete a user in Linux is crucial, whether you need to remove an unused account, revoke access for a departing employee, or clean up your system for security reasons. Here, we will explore the 'userdel
5 min read
vi Editor in Linux The default editor that comes with the Linux/UNIX operating system is called vi (visual editor). Using vi editor, we can edit an existing file or create a new file from scratch. we can also use this editor to just read a text file. The advanced version of the vi editor is the vim editor. Table of C
9 min read
vmstat command in Linux with Examples vmstat command in Linux/Unix is a performance monitoring command of the system as it gives the information about processes, memory, paging, block IO, disk, and CPU scheduling. All these functionalities makes the command vmstat also known as virtual memory statistic reporter. The very first report pr
3 min read
vnstat command in Linux with Examples vnstat is a command-line tool in Linux that is generally used by system administrators in order to monitor network parameters such as bandwidth consumption or maybe some traffic flowing in or out. It monitors the traffic on the system's network interfaces. Installing vnstat on LinuxIn case of RedHat
4 min read
w command in Linux with Examples The 'w' command in Linux gives us important information about who is currently using the computer, how much the computer is being used, and what programs are running. It's a handy tool for people who take care of computer systems, as it helps them keep an eye on what users are doing, how much of the
3 min read