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





