+5 votes
231 views
How to use who command in Linux

in Linux / Unix by (552k points)
reopened | 231 views

1 Answer

+3 votes
Best answer

How to use who command in Linux

When under our responsibility we have Linux systems, it is ideal and fundamental to have knowledge about some commands that will be of great help when carrying out administration, management or support tasks to know in detail multiple parameters of both the system and processes, users, services and much more..

Needed information
In specific moments of these tasks, it will be necessary to know basic information such as:
  • Last system boot time
  • List of connected users
  • Current execution level and many more.

This type of information is available in multiple Linux files, but we have a command that allows us to obtain this same information in a much more simplified way and it is the who command. Who is a useful command to generate varied system information to facilitate our administrative task and today in TechnoWikis we will see some options on how to use this command in a practical way.

How to use who command in Linux

Step 1

The basic syntax of its use is:
 who [OPTION] ... [FILE | ARG1 ARG2] 
When we run who without any argument, the account information will be displayed with details such as username, user terminal, login time and host time in which you have logged in as follows: image
Step 2

We can use the following options:
Show header
If we want to print the header of the generated columns, we must use the -H parameter as follows:
 who -H 
image
View names and connected users
To print the login names and the total number of connected users on the screen, simply use the -q parameter like this:
 who -q 
image
Display hostname and associated user
If the objective is to display only the host name and the user associated with stdin, we can use the -m parameter:
 who -m 
image
See last operating system boot
To display the time of the last boot of the selected system, it is useful to use the -b parameter and add the -u option to list the connected users in the same result as follows:
 who -b -u 
image
Check the level of execution
The who command allows us to verify the current execution level with the -r option like this:
 who -r 
image
Generate general information
With the -a parameter it will be possible to print the default result combined with the information of some of the previous options:
 who -a 
image
Help from who
To display the general help of who we can execute the following:
 man who 
image
Step 3

Some of its other options are:
-a, --all
It generates the same result as the options
 -b -d --login -p -r -t -T -u 
-b, --boot
Displays the time of the last system startup.
-d, --dead
Deploy dead processes.
-H, --heading
Print a line of column headings.
--ips
Print IP addresses instead of host names.
-l, --login
It is responsible for printing system login processes.
--lookup
An attempt is made to canonicalize host names through DNS.
-m
This option only prints information about the user and host associated with the standard input, that is, the equipment where the command was issued. This method adheres to the POSIX standard.
-p, --process
Print active processes generated by init.
-q, --count
It is responsible for generating all login names and a count of all users who have logged in there.
-r, --runlevel
With this option the current execution level is printed.
-s, --short
Print only name, line and time fields, which is the default.
-t, --time
Using this option prints the last time the system clock was changed, if the information is available for it.
-T, -w, --mesg
It allows us to add a character that indicates the status of the terminal line: "+" if the terminal is writable, "-" if it is not, or "?" If a bad line is found.
-u, --users
Print the idle time for each user and the process ID.
--message
Its use is the same as -T.
-writable
It is the same as -T.
--help
Display a help message and exit the command.
--version
Generate the version information of the who command.
image

We can see how this simple command is of great help in obtaining information for multiple tasks at the Linux level..


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Oct 20, 2020 in Linux / Unix by backtothefuture (552k points) | 240 views
+4 votes
1 answer
asked Sep 22, 2020 in Linux / Unix by backtothefuture (552k points) | 334 views
+3 votes
1 answer
asked Nov 9, 2019 in Linux / Unix by backtothefuture (552k points) | 303 views
+5 votes
1 answer
asked Sep 19, 2019 in Linux / Unix by backtothefuture (552k points) | 313 views
+3 votes
1 answer
asked Sep 17, 2019 in Linux / Unix by backtothefuture (552k points) | 288 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users