I would like to see how many users are on my system. How could I view a list of all the users on the system?
Asked
Active
Viewed 5.8k times
30
3 Answers
32
You can get a list of all users with
getent passwd | cut -d':' -f1
This selects the first column (user name) of the system user database. In contrast to solutions parsing /etc/passwd
, this will work regardless of the type of database used (traditional /etc/passwd
, LDAP, etc). Note that this list includes system users as well (e.g. nobody, mail, etc.).
The exact user number can be determined as follows:
getent passwd | wc -l
A list of currently logged in users can be obtained with the users
or who
command:
users # or
who

Marco
- 33,548
-
Why not use
getent passwd
to get the current user list, including users found via LDAP etc.? Also,wc -l
would be a far shorter way to count the lines in/etc/passwd
(or the output ofgetent passwd
, for that matter). – n.st Jan 27 '15 at 14:20 -
-
That will not necessarily list all the user's. Some user databases can be made non-enumeratable – Stéphane Chazelas Jan 28 '15 at 00:05
4
You could simply cat
the /etc/passwd
file or use,
awk -F':' '{ print $1}' /etc/passwd
To cut the first field of the same file, it'd list the names you're expecting.
Additonally, w
who
and finger
would help you with who all are logged in from which locations/tty and their activity details.

Keyshov Borate
- 1,319
/etc/passwd
would help you. – Roman Kiselenko Jan 27 '15 at 10:59