Linux who Command
The Linux who
command is used to display which users are currently logged into the system. The displayed information includes the user ID, terminal in use, source of connection, login time, idle time, CPU usage, and actions.
Permission: All users can use this command.
Syntax
who - [husfV] [user]
Parameter Description:
- -H or --heading: Display the title information for each column;
- -i or -u or --idle: Display the idle time. If the user has performed any action within the last minute, it will be marked with a "." symbol. If the user has been inactive for more than 24 hours, it will be marked with the string "old";
- -m: This parameter has the same effect as specifying the string "am i";
- -q or --count: Only display the login account names and the total number of users;
- -s: This parameter is ignored and is only responsible for resolving compatibility issues with other versions of the
who
command; - -w or -T or --mesg or --message or --writable: Display the user's information status bar;
- --help: Online help;
- --version: Display version information.
Examples
Display currently logged-in users
# who //Display currently logged-in users
root tty7 2014-05-13 12:12 (:0)
root pts/0 2014-05-14 17:09 (:0.0)
root pts/1 2014-05-14 18:51 (192.168.1.17)
root pts/2 2014-05-14 19:48 (192.168.1.17)
Display title bar
# who -H
NAME LINE TIME COMMENT
root tty7 2014-05-13 12:12 (:0)
root pts/0 2014-05-14 17:09 (:0.0)
root pts/1 2014-05-14 18:51 (192.168.1.17)
root pts/2 2014-05-14 19:48 (192.168.1.17)
Display user login source
# who -l -H
NAME LINE TIME IDLE PID COMMENT
LOGIN tty4 2014-05-13 12:11 852 id=4
LOGIN tty5 2014-05-13 12:11 855 id=5
LOGIN tty2 2014-05-13 12:11 862 id=2
LOGIN tty3 2014-05-13 12:11 864 id=3
LOGIN tty6 2014-05-13 12:11 867 id=6
LOGIN tty1 2014-05-13 12:11 1021 id=1
Display terminal attributes
# who -T -H
NAME LINE TIME COMMENT
root + tty7 2014-05-13 12:12 (:0)
root + pts/0 2014-05-14 17:09 (:0.0)
root - pts/1 2014-05-14 18:51 (192.168.1.17)
root - pts/2 2014-05-14 19:48 (192.168.1.17)
Only display the current user
# who -m -H
NAME LINE TIME COMMENT
root pts/1 2014-05-14 18:51 (192.168.1.17)
Display in concise mode
# who -q
root root root root
# users=4