Bootstrap FreeKB - Linux Commands - w (view logged in users)
Linux Commands - w (view logged in users)

Updated:   |  Linux Commands articles

The command without any options can be used to view the users that are logged in. The who and last commands are similar to the w command. In this example, there are two users logged in, root and john.doe. The second column shows the virtual console being used. In this example, john.doe is using /dev/pts/0 and root is using /dev/pts/1.

[root@server1 ~]# w
20:31:48 up 3 days, 7:12, 2 users, load average: 0.35, 0.42, 0.41
USER     TTY      FROM                    LOGIN@   IDLE     JCUP    PCPU    WHAT
john.doe pts/0    server1.example.com     Sun13    4.00s    0.47s   0.30s   gnome-terminal
root     pts/1    server1.example.com     Mon20    3 days   1:33    1.79s   cinnamon-session

 


View a single user

The w command followed by a username can be used to display only a certain user. In this example, only john.doe is displayed.

[root@server1 ~]# w john.doe
20:31:48 up 3 days, 7:12, 2 users, load average: 0.35, 0.42, 0.41
USER     TTY      FROM                   LOGIN@   IDLE     JCUP    PCPU    WHAT
john.doe pts/0    server1.example.com    Sun13    4.00s    0.47s   0.30s   gnome-terminal

 


Remove header

The -h or --no-header option can be used to remove the header from the output.

[root@server1 ~]# w -h
john.doe pts/0    server1.example.com    Sun13    4.00s    0.47s   0.30s   gnome-terminal
root     pts/1    server1.example.com    Mon20    3 days   1:33    1.79s   cinnamon-session

 


Remove columns

The -s or --short option can be used to remove the LOGIN, JCUP and PCPU columns.

[root@server1 ~]# w
20:31:48 up 3 days, 7:12, 2 users, load average: 0.35, 0.42, 0.41
USER     TTY      FROM                  IDLE     WHAT
john.doe pts/0    server1.example.com   4.00s    gnome-terminal
root     pts/1    server1.example.com   3 days   cinnamon-session

 


Show IP address instead of hostname

The -i or --ip-addr option can be used to display IP addresses instead of hostnames. In this example, instead of displaying server1.example.com, IP address 192.168.0.17 is displayed.

[root@server1 ~]# w
20:31:48 up 3 days, 7:12, 2 users, load average: 0.35, 0.42, 0.41
USER     TTY      FROM             LOGIN@   IDLE     JCUP    PCPU    WHAT
john.doe pts/0    192.168.0.17     Sun13    4.00s    0.47s   0.30s   gnome-terminal
root     pts/1    192.168.0.17     Mon20    3 days   1:33    1.79s   cinnamon-session

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 6e1825 in the box below so that we can be sure you are a human.