The user and group databases are plain files, so listing them needs no special tool, no root. Read them with getent, which also covers users defined in LDAP or other directory backends, not just /etc/passwd:
getent passwd # every user
getent group # every group
Just the usernames
The first colon-separated field of each line is the name:
getent passwd | cut -d: -f1 # all usernames
getent group | cut -d: -f1 # all group namescut -d: -f1 splits on the colon and keeps field one. (For more on slicing columns, see grep and print a specific column.)
Human accounts vs system accounts
Most entries in /etc/passwd are system accounts (daemon, www-data, sshd), not people. They are separated by UID. On most distros, regular human accounts start at UID 1000:
# Real login users (UID >= 1000, excluding nobody at 65534)
getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 {print $1}'The third field ($3) is the UID. That one-liner is the honest answer to "who can actually log in here". (awk -F: sets the field separator to a colon.)
Which groups is one user in?
groups deploy # group names for one user
id deploy # names plus UIDs and GIDsAnd the reverse, who is in a group:
getent group developers # the member list is the last colon fieldFAQ
Filter by UID. Human accounts almost always start at 1000: getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 {print $1}'. System and service accounts use lower UIDs and are not meant for interactive login.
cat /etc/passwd only shows local accounts. getent passwd queries the full Name Service Switch stack, so it also returns users from LDAP, SSSD, or other directory backends configured in /etc/nsswitch.conf. On a standalone box the output is the same; on a managed fleet it is not.
getent group developers prints the group line; the comma-separated member list is the final colon-separated field. Note it shows only secondary members, not users whose primary group it is, so cross-check with id username.
See also
- How to Create a User on Linux: add the accounts you are listing.
- How to Add a User to a Group: change the memberships you see here.
- How to grep and print a specific column: more ways to slice these colon-delimited files.
- How to Create a Group on Linux: primary vs secondary group membership.
Sources
Authoritative references this article was fact-checked against.





