How to List All Users on Ubuntu/Linux: Every Method Explained
Whether you are auditing a server, troubleshooting access, or simply taking inventory of who can log in, knowing how to list all users on Ubuntu is a core Linux administration skill. The challenge is that Ubuntu does not have a single “show users” button, and most of the accounts you will see are not people at all. They are system and service accounts created automatically by the operating system and installed software.
This guide walks through every reliable method to list users on Ubuntu and other Linux distributions, explains the difference between human login users and system accounts, and shows you how to filter, count, and locate specific users using simple command-line tools.
Key Takeaways
• The fastest way to see all defined users is `getent passwd` or `cut -d: -f1 /etc/passwd`.
• Most accounts in `/etc/passwd` are system/service accounts, not real people.
• Human login users almost always have a UID of 1000 or higher — filter with `awk -F: ‘$3>=1000’`.
• `getent passwd` is more complete than `cat /etc/passwd` because it also returns network/LDAP users.
• `who` and `w` show currently logged-in users, not every account on the system.
Where Are Users Defined on Ubuntu?
Before listing users, it helps to understand where Ubuntu stores account information. User data lives across a few plain-text files:
- `/etc/passwd` — the primary user database. It holds the username, user ID (UID), group ID (GID), home directory, and login shell for every local account. Despite its name, it no longer stores passwords.
- `/etc/shadow` — stores encrypted passwords and password-aging policies. Readable only by root.
- `/etc/group` — defines groups and their members.
Every line in `/etc/passwd` represents one account and uses colon-separated fields:
“` username:x:1000:1000:Full Name:/home/username:/bin/bash “`
The third field (`1000` above) is the UID. This single number is the key to telling humans apart from machine accounts, as you will see shortly.
How Do You List All Users From /etc/passwd?
The most direct method is to read `/etc/passwd` itself. To see the full file with all account details:
“`bash cat /etc/passwd “`
This prints every account with all fields. If you only want the usernames, extract the first field with `cut`:
“`bash cut -d: -f1 /etc/passwd “`
Here `-d:` sets the colon as the delimiter and `-f1` selects the first field. For an alphabetically sorted list, pipe it through `sort`:
“`bash cut -d: -f1 /etc/passwd | sort “`
This works on essentially every Linux distribution because `/etc/passwd` is part of the POSIX standard. The catch is that it only shows accounts defined locally on this machine.
Why Is getent passwd Better Than cat /etc/passwd?
The `getent` command queries the system’s configured name service databases, which include `/etc/passwd` plus any networked sources such as LDAP, NIS, or Active Directory that the server is configured to use through `/etc/nsswitch.conf`.
“`bash getent passwd “`
To list just the usernames:
“`bash getent passwd | cut -d: -f1 “`
On a standalone server, `getent passwd` and `cat /etc/passwd` often return identical results. But on a server joined to a corporate directory, only `getent` will reveal the centrally managed users. For that reason, `getent passwd` is the more complete and reliable choice when you want to be certain you have captured every user.
How Do You List Only Human (Login) Users?
Run `cat /etc/passwd` on a fresh Ubuntu install and you will count dozens of entries — `root`, `daemon`, `bin`, `sys`, `www-data`, `sshd`, and many more. Almost none of these are people. They are system and service accounts that software uses to run with limited privileges.
The reliable way to separate the two groups is the UID convention:
- System/service accounts: UID below 1000 (typically 0–999). The exception is `root`, which is always UID 0.
- Human login users: UID 1000 or higher, assigned automatically when you create a normal account.
Filter for real users with `awk`:
“`bash awk -F: ‘$3>=1000 {print $1}’ /etc/passwd “`
This reads `/etc/passwd`, splits each line on the colon (`-F:`), and prints the username (`$1`) only when the UID (`$3`) is 1000 or greater. Combine it with `getent` to also catch directory-based users:
“`bash getent passwd | awk -F: ‘$3>=1000 {print $1}’ “`
This is the single most useful command in this guide for answering the real question behind “list all users”: *who are the actual people with accounts on this server?*
You can also tighten the range to exclude the special `nobody` account (UID 65534 on Ubuntu):
“`bash awk -F: ‘$3>=1000 && $3<65534 {print $1}' /etc/passwd ```
Are There Other Ways to List Users?
Yes. A few additional tools come in handy depending on the shell and situation.
`compgen -u` is a Bash built-in that lists all usernames the shell knows about. It is quick to type and useful in scripts:
“`bash compgen -u “`
`who` and `w` show users who are currently logged in, not every account on the system:
“`bash who w “`
Use these when you want to know who is active right now — for example, before rebooting a shared server. They are not a substitute for the full account list.
Here Is a Quick Reference of Commands to List Users
| Command | What It Shows | |
|---|---|---|
| `cat /etc/passwd` | Every local account with all fields (UID, home, shell) | |
| `cut -d: -f1 /etc/passwd` | Usernames only, from the local file | |
| `getent passwd` | All accounts including network/LDAP sources (most complete) | |
| `getent passwd \ | cut -d: -f1` | Usernames only, including network sources |
| `awk -F: ‘$3>=1000 {print $1}’ /etc/passwd` | Human/login users only (UID ≥ 1000) | |
| `compgen -u` | All usernames the shell recognizes | |
| `who` / `w` | Users currently logged in (not all accounts) | |
| `id username` | UID, GID, and groups for one specific user |
How Do You Count Users on Ubuntu?
To count something on the command line, pipe the output into `wc -l`, which counts lines.
Count all accounts:
“`bash getent passwd | wc -l “`
Count only human users (UID ≥ 1000):
“`bash getent passwd | awk -F: ‘$3>=1000’ | wc -l “`
This is a fast way to verify that user cleanup ran correctly or to confirm how many real accounts exist before a migration.
How Do You Find or Verify a Specific User?
When you need details about one account rather than the whole list, two commands do the job.
The `id` command shows the UID, primary group, and all supplementary groups:
“`bash id deploy “`
If the account exists, you get its IDs and group memberships. If it does not, `id` reports “no such user” — a quick existence check.
The `getent passwd` command with a username returns that user’s full `/etc/passwd` line, including home directory and shell:
“`bash getent passwd deploy “`
You can also grep the file directly, though `getent` is cleaner and covers network users:
“`bash grep ‘^deploy:’ /etc/passwd “`
DarazHost: Full Root Access to Manage Your Linux Users
Listing, adding, and removing users requires administrative control over the server — something shared hosting plans rarely provide. With a DarazHost VPS or dedicated server, you get full root access to manage Linux users exactly the way this guide describes: create accounts, set permissions and group membership, audit who can log in, and remove stale users without restrictions.
Our Linux servers come with reliable uptime, generous resources, and 24/7 technical support, so whether you are running a single application or a multi-user environment, you stay in complete control of your system. If you need a clean Ubuntu or other Linux environment with real administrative access, give you the foundation to manage users and services your way.
Best Practices for Managing the User List
- Audit regularly. Run `getent passwd | awk -F: ‘$3>=1000 {print $1}’` periodically to catch accounts that should have been removed.
- Never delete system accounts. Removing UID < 1000 accounts can break services. Stick to UID ≥ 1000 when cleaning up.
- Disable instead of delete when unsure — locking an account (`usermod -L`) is reversible.
- Check group membership with `id` before granting access, so you understand a user’s effective privileges.
Frequently Asked Questions
What command lists all users in Ubuntu? Use `getent passwd` for the complete list including network accounts, or `cut -d: -f1 /etc/passwd` to get only the usernames from the local file. To see just human login users, run `awk -F: ‘$3>=1000 {print $1}’ /etc/passwd`.
Why are there so many users I never created? Most entries in `/etc/passwd` are system and service accounts (such as `www-data`, `sshd`, and `daemon`) created automatically by Ubuntu and installed software. They have UIDs below 1000 and exist so services can run with restricted privileges rather than as root.
How do I list only real human users? Filter by UID with `awk -F: ‘$3>=1000 {print $1}’ /etc/passwd`. Human accounts are assigned a UID of 1000 or higher, while system accounts use lower numbers. The `root` account is the exception at UID 0.
What is the difference between who, w, and listing all users? `who` and `w` show users who are currently logged in during this session, not every account configured on the system. To see all accounts, use `getent passwd` or read `/etc/passwd`.
Does cat /etc/passwd show every user? It shows every local account, but it will miss users provided by network directory services such as LDAP or Active Directory. Use `getent passwd` instead to capture both local and network-defined users.
Conclusion
Listing users on Ubuntu comes down to choosing the right tool for the question. Use `getent passwd` for the most complete account list, `cut` to pull out usernames, and the `awk -F: ‘$3>=1000’` filter to focus on real people instead of system accounts. For one-off checks, `id` and `getent passwd username` give you everything you need about a single account. Master these commands and you will always know exactly who has access to your server.