This guide covers ten practical ways to list user accounts on Red Hat Enterprise Linux 8, from quick terminal checks to methods that show account details or distinguish system accounts from people. It is for administrators and Linux users who need to inspect local users, check identity-service accounts, or save a list for later review.
1. Read /etc/passwd
Run cat /etc/passwd to display the system’s local account records. Each line has seven colon-separated fields, including the username, user ID (UID), group ID, home directory, and login shell; the password field is normally represented by x, not a password. This is a direct, useful view of local accounts, but it does not include users supplied only by LDAP or another identity provider.
2. Show Only Usernames with cut
Use cut -d: -f1 /etc/passwd to extract the first field from each local account record. This produces a compact, one-name-per-line list that is easier to scan or pass to another command than the full file. It still includes service and system accounts, so it should not be treated as a list of human users without filtering.
3. Use getent passwd for NSS Accounts
Run getent passwd to query the Name Service Switch (NSS), which can combine local files with configured identity sources such as LDAP or SSSD. This is generally the right choice when you want the accounts the host can resolve, rather than only entries physically stored in /etc/passwd. The result depends on the machine’s NSS configuration and network availability, so a remote directory outage can affect what appears.
4. Query One Account with getent
To check whether a particular account is resolvable, run getent passwd username, replacing username with the account name. A matching record confirms that NSS can look it up and shows its UID, primary GID, home directory, and shell. This targeted check is convenient for troubleshooting a login or script; it does not prove that the user can authenticate successfully.
5. List Accounts with compgen
In Bash, compgen -u prints usernames available through the shell’s account-completion mechanism. It is a short command for quick interactive checks and often reflects accounts known through the system’s configured account lookup. Because it is Bash-specific and its output can include service accounts, use getent passwd when you need a more explicit, portable account-record query.
6. Find Human-Style Accounts by UID
Many RHEL installations assign regular users UIDs starting at 1000, while system accounts use lower values; inspect the local policy in /etc/login.defs before relying on that convention. For local accounts, this command shows entries at or above 1000: awk -F: '$3 >= 1000 {print $1, $3, $6, $7}' /etc/passwd. It is a useful starting filter, not a universal definition of a person: administrators can set different UID ranges, and directory users may not be listed in this file.
7. Check Local Accounts with vipw -s
sudo vipw -s opens the local shadow-password file using a tool designed to help prevent simultaneous edits from corrupting account data. It can help an authorized administrator compare shadow entries with /etc/passwd, but it is not the usual way to obtain a username list and requires elevated access. Do not expose or copy shadow-file contents casually: they contain password hashes and account-aging information.
8. Inspect Account Details with id
Run id username to see a user’s UID, primary group, and supplementary groups, or run id to inspect the current account. This does not list every user, but it is valuable after finding a name because group membership often explains access to files and services. For a directory-managed account, the result depends on NSS being able to resolve that account.
9. Use the getent passwd Output with awk
Combine NSS lookup with field selection: getent passwd | awk -F: '{print $1, $3, $6, $7}' prints each resolved username, UID, home directory, and shell. This retains the broader account coverage of getent while making the output easier to review or redirect to a text file. Treat the result as a snapshot: directory data can change, and the output may contain technical accounts as well as people.
10. View Users in the RHEL Web Console
If the RHEL 8 web console is installed and enabled, sign in to Cockpit and open the Accounts page to review accounts through a graphical interface. It is helpful for administrators who prefer a visual overview and want to inspect account details without parsing colon-separated fields. Availability depends on the system’s Cockpit packages and configuration; use the terminal commands above when the console is not installed or remote access is unavailable.
How to Choose
First decide whether you need only local accounts or every account the host can resolve. Choose /etc/passwd or a command that reads it for a local-file audit; choose getent passwd for a host using NSS-backed services such as SSSD or LDAP. For a clean list of names, use cut or awk; to investigate one account, use getent passwd username and id username.
Next, decide whether “users” means all accounts or likely human accounts. System services also need accounts, so do not delete or disable names merely because they look unfamiliar; verify ownership and purpose first. UID filtering can narrow a list, but check the configured UID range and remember that remote identity sources may follow different conventions. If you are preparing an audit, note the command, host, and time, and handle any output containing sensitive account information appropriately.
Frequently Asked Questions
What is the fastest command to list usernames on RHEL 8?
For local usernames, use cut -d: -f1 /etc/passwd. To include accounts resolved through configured identity services, use getent passwd.
Why does /etc/passwd not show all users?
It stores local account records. Users provided by LDAP, Active Directory through an identity integration, or another NSS source may be resolvable without having a line in that file.
How can I list only normal users?
Check the UID range configured on the machine, then filter accordingly. UID 1000 is a common starting point for regular users on RHEL, but it is a convention, not a guarantee that every matching account belongs to a person.
Does listing an account mean it can log in?
No. The account may have a locked password, a non-login shell, expired credentials, access restrictions, or an unavailable identity provider. Check the relevant authentication and access policies as well.
How do I save a user list to a file?
For example, use getent passwd | cut -d: -f1 > users.txt. The file contains names returned at that moment; protect it if account names or other identifying information are sensitive.
Final Thoughts
For a quick local list, extract names from /etc/passwd; for accounts visible through RHEL’s configured identity services, start with getent passwd. Choose filters based on the task, and verify account purpose before making access changes.