How to List Users on Ubuntu
Show every account on an Ubuntu system, tell the people apart from the service accounts, and see who has sudo. Tested on 26.04, 24.04 and 22.04.
There’s no listusers command, which is why this comes up so often. Accounts live in /etc/passwd, and reading it is the answer to all four versions of the question.
Before You Start
- A server or desktop running Ubuntu 26.04, 24.04 or 22.04
None of this needs sudo. /etc/passwd is world-readable, despite the name: passwords moved to /etc/shadow a long time ago.
Step 1: List Every Account
cut -d: -f1 /etc/passwd
root
daemon
bin
sys
Thirty-odd lines on a fresh server, nearly all of them service accounts that exist to own files and run daemons.
Step 2: List Just the People
Accounts made for humans start at UID 1000. Service accounts sit below it.
awk -F: '$3 >= 1000 && $3 < 65534 { print $1 }' /etc/passwd
ubuntu
The upper bound drops nobody, which sits at 65534 and isn’t a person either.
Step 3: See Who Has sudo
getent group sudo
sudo:x:27:ubuntu
The names after the third colon are the members. On Ubuntu that’s the group that grants administrative rights, so this is the list worth checking after somebody hands a server over to you.
Verify It Worked
The filter in step 2 is the one that can quietly lie to you, by hiding an account or inventing one. Your own login is a known-good answer, so check it comes back:
awk -F: '$3 >= 1000 && $3 < 65534 { print $1 }' /etc/passwd | grep -c "^$(whoami)$"
1
1 means your account is in the list exactly once, and the UID range is doing what it claims.
Conclusion
Four commands, and between them they answer who exists, who’s a person, and who can escalate. If you’re about to add somebody to that list, adding a user and giving them sudo is the next one.
If something here doesn’t match what you’re seeing, do drop me a line at [email protected] with the Ubuntu version you’re on and I’ll get it retested.