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:
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:
Parameter | Description |
---|---|
file | Show information on a specific file or terminal |
How to use who command:
Display currently logged in users
This command will display a list of users who are currently logged into the system.
Display only the usernames of the logged in users
Using the -q option will show only the usernames of the logged in users.
Display all information about the logged in users with headings
The -H option displays all information about the logged in users along with headings.
Display the time the system was last booted
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
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
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
This command will display only the user’s current session information.
Show only the login and logout time for the current user
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?
To use the who command in Linux, execute the following command:
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.
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.
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.
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.
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.
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.
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.
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.
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