Cart 0
No products in the cart.

How to use W command in Linux ?

How to use W command in Linux ?

The W command in Linux is a command line utility that is used to display information about users who are currently logged into the system. It displays the username, login time, idle time, JCPU and PCPU times, and the host from which the user is logged in. This command is useful for monitoring user activity on a system, and can also be used to troubleshoot user issues or to ensure system security. 

Here at Fixwebnode, we will look at how to use the W command in Linux with practical examples.

 

What is the syntax of W Command ?

The basic syntax of the W command is as follows: 

$ w

This command will display a list of all the users currently logged into the system, along with their login time, idle time, JCPU and PCPU times, and the host from which the user is logged in. 

 

W Command Options

When using the W command, there are several options that can be used to customize the output. 

These options include:

  • -u: Displays information about the currently logged in users.
  • -s: Displays system load averages.
  • -h: Display the help page.

 

Example of using W Command

1. Displaying User Information

The W command can be used to view detailed information about a particular user. To do this, you need to pass the username as an argument to the command. 

$ w username
username  pts/0        2023-03-20 09:17:49 - 0:00  1:00.41  0.44s  192.168.1.7

 

2. Displaying Process Information

The W command can also be used to view information about the processes that a user is running. To do this, you need to pass the -p option to the command. 

$ w -p username
username  pts/0        2023-03-20 09:17:49 - 0:00  1:00.41  0.44s  192.168.1.7  bash

 

4. Displaying System Uptime

The W command can be used to view the system uptime. To do this, you need to pass the -s option to the command. 

$ w -s
up 5 days, 3:41,  0 users,  load average: 0.00, 0.00, 0.00

 

5. Displaying All Information

The W command can be used to view all the information about a user, including their login time, idle time, JCPU and PCPU times, and the host from which they are logged in. To do this, you need to pass the -a option to the command. 

$ w -a username
username  pts/0        2019-03-20 09:17:49 - 0:00  1:00.41  0.44s  192.168.1.7  bash  0.00s  0.00s

 

6. Displaying Users from a Specific Host

The W command can be used to view all the users that are logged in from a specific host. To do this, you need to pass the hostname as an argument to the command. 

$ w hostname
username  pts/0        2019-03-20 09:17:49 - 0:00  1:00.41  0.44s  192.168.1.7

 

[Need Technical Support ? We are available. ]

 



CONCLUSION

This article will cover how to use the W command in Linux explained with practical examples. In fact, We have seen how to use the command to view information about users, processes, system uptime, and users from a specific host.

 

How to fix W command not found in UbuntuLinux ?

1. First, open the Terminal on your Ubuntu machine.

 

2. If the 'W' command is not found, then you can install it using the following command:

$ sudo apt-get install w

 

3. Once the installation is complete, you should be able to use the 'W' command by typing 'w' followed by the username you wish to find out information on.

 

4. If you are still having issues with the 'W' command not being found, then you can try reinstalling the command from the Ubuntu repository by running the following command:

$ sudo apt-get install --reinstall w

 

5. After the reinstallation is complete, you can try running the 'W' command again and it should now be working properly.

 


icon

Sign up to Newsletter

...and receive a free support ticket.