Open In App

w command in Linux with Examples

Last Updated : 31 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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:

Columns

Description

USER

Displays the username of the logged-in user.

TTY

Shows the terminal device associated with the user session.

FROM

Indicates the remote host or IP address the user is connected to

LOGIN@

Displays the time at which the user logged in.

IDLE

Shows the duration of inactivity since the user’s last interaction.

JCPU

Represents the CPU time used by all processes attached to the user’s session.

PCPU

Displays the percentage of CPU time used by the user’s current process.

WHAT

WHAT: Provides information about the command or process running in the user’s session.

Options Available in `w` command in Linux

Options

Description

-h

Suppresses the header row from being displayed in the output.

-u

Ignores the username when calculating the current process and CPU times.

-s

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.

-f

Toggles the printing of the ‘from’ field (remote hostname). By default, it is not printed, but this option can change that.

–help

Displays a help message that provides information about the usage and options of the ‘w’ command.

-i

Displays the IP address instead of the hostname in the ‘from’ field.

-V

Displays version information about the ‘w’ command.

-o

Prints a blank space for idle times that are less than one minute.

user

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.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads