Which is the command that can be used to see the list of users who are currently logged-in? This tutorial explains how to check how many users are logged in Linux Ubuntu.
Read to find out how to check user details in Linux:
1. W command
The w command is used to show who is logged on and what they are doing. The w command displays information about the users currently on the machine, and their processes.
It must be noted that the information displayed – header shows – in this order:
- the current time
- how long the system has been running
- how many users are currently logged on
- the system load averages for the past 1, 5, and 15 minutes.
For each user the following entries are displayed:
- login name
- the tty name
- the remote host
- login time
- idle time,
- JCPU, PCPU
- the command line of their current process
If you don’t want to print the login time, JCPU or PCPU times, run the W command with -s or –short argument. This is used to display the information in the short format. Don’t print the login time, JCPU or PCPU times.
2. who command
The who command prints information about users who are currently logged on. When you run the command without any argument, ‘who’ prints the following information for each user currently logged on:
- login name
- terminal line
- login time
- remote hostname or X display
If given two non-option arguments, the ‘who’ command prints only the entry for the user running it which is preceded by the hostname.
The most command argument for the who command is ‘am i’, as in ‘who am i’.
If you want to print only the login names and the number of users logged on you can use the ‘-q’ or ‘–count’ argument with the who command. It will override all other options.
3. users command
The users command is used to print login names of users currently logged in. When you execute the command the ‘users’ prints on a single line a blank-separated list of user names of users currently logged in to the current host.
Note that each user name corresponds to a login session, so if a user has more than one login session, that user’s name will appear the same number of times in the output.
I hope this quick tutorial will be useful for you in finding the users currently logged on.