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?
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