who command in Linux
The who
command in Linux is used to display information about currently logged-in users on a Unix system. It shows the username, terminal, and time when the user logged in. Additionally, it can display the host from which the user is logged in. This command can be useful for system administrators to monitor user activity and manage resource allocation on the system.
who Syntax:
Section titled “who Syntax:”who [option] [file]
Linux who Options:
Section titled “Linux who Options:”Option | Description |
---|---|
-b | Time of last system boot |
-d | Dead processes |
-H | Display column headers |
-l | Time of last login |
-q | List all login names |
-u | List all processes started by any user |
who Parameters:
Section titled “who Parameters:”Parameter | Description |
---|---|
file | Show information on a specific file or terminal |
How to use who command:
Section titled “How to use who command:”Display currently logged in users
Section titled “Display currently logged in users”who
This command will display a list of users who are currently logged into the system.
Display only the usernames of the logged in users
Section titled “Display only the usernames of the logged in users”who -q
Using the -q option will show only the usernames of the logged in users.
Display all information about the logged in users with headings
Section titled “Display all information about the logged in users with headings”who -H
The -H option displays all information about the logged in users along with headings.
Display the time the system was last booted
Section titled “Display the time the system was last booted”who -b
By using the -b option, you can see the time when the system was last booted.
Display a list of currently logged in users and their IP addresses
Section titled “Display a list of currently logged in users and their IP addresses”who -u
Using the -u option will show a list of currently logged in users along with their IP addresses.
Show the pid and time each user has been idle
Section titled “Show the pid and time each user has been idle”who -u -p
By using both -u and -p options, you can see the process ID and the time each user has been idle.
Display only the line of information including the current user
Section titled “Display only the line of information including the current user”who am i
This command will display only the user’s current session information.
Show only the login and logout time for the current user
Section titled “Show only the login and logout time for the current user”who -u am I
Using -u on the user “am I” will display the login and logout time for the current user.
How do I use who in Linux?
Section titled “How do I use who in Linux?”To use the who command in Linux, execute the following command:
who
What is the output of the who command?
Section titled “What is the output of the who command?”The who command displays information about users who are currently logged into the system, as well as their login names, terminal line numbers, login times, and more.
who
How can I display only the username and terminal of logged-in users?
Section titled “How can I display only the username and terminal of logged-in users?”You can use the who command with the -q
or --query
option to display only the username and terminal of logged-in users.
who -q
How do I display the time of last system boot using who?
Section titled “How do I display the time of last system boot using who?”You can use the who command with the -b
or --boot
option to display the time of the last system boot.
who -b
Can I get the run level of the system with who?
Section titled “Can I get the run level of the system with who?”Yes, you can use the who command with the -r
or --runlevel
option to display the current and previous run levels of the system.
who -r
How can I show the dead processes with who?
Section titled “How can I show the dead processes with who?”You can use the who command with the -d
or --dead
option to display dead processes that are not properly removed from the UTMP file.
who -d
How can I display the hostname of the system using who?
Section titled “How can I display the hostname of the system using who?”To display the hostname of the system along with user information, you can use the who command with the -m
or --mesg
option.
who -m
Can I see all login processes with who?
Section titled “Can I see all login processes with who?”Yes, you can use the who command with the -p
or --processes
option to show all login processes along with other information.
who -p
How do I show only the count of logged-in users with who?
Section titled “How do I show only the count of logged-in users with who?”To display only the count of logged-in users, you can use the who command with the -q
option followed by the --count
option.
who -q --count
Applications of the who command
Section titled “Applications of the who command”- Display information about who is logged on
- Show the username, terminal, login time, and IP address of each user
- Display idle time and system boot time for each user
- Check for multiple logins by the same user
- Monitor and track user activity and login sessions