#

Users Permissions

Subscribe
Users Permissions October 29, 2026·6 min read

How to List Users in Linux: Accounts, NSS, and Sessions

Use /etc/passwd for local accounts, getent passwd for accounts NSS can enumerate, and who for current sessions. If a directory user is missing, run getent passwd USER and id USER for that name. If access is your real question, check login permissions separately, because no single command shows who can log in.

Which Linux user list do you need?

Linux user commands

Linux has several answers to "Who are the users on this system?" If an account is absent from /etc/passwd, check whether it comes from an NSS source before concluding that the username does not exist on the system.

What you needCommandWhat it returnsWhat it does not proveDetails below
Local usernamescut -d: -f1 /etc/passwdNames stored in the local passwd fileNetwork directory membershipLocal accounts
Local account detailscat /etc/passwdSeven-field local recordsSuccessful authenticationLocal accounts
Enumerable NSS accountsgetent passwdRecords exposed by NSS enumerationEvery directory accountNSS lookup
One usernamegetent passwd USERThe record for that namePermission to connect over SSHLookup by name
Regular or system categorieslslogins -u / lslogins -sConfigured account classificationsWhether a person owns the accountAccount types
Current login sessionswhoRecorded sessionsEvery configured accountSessions

List local Linux accounts with /etc/passwd

Linux passwd records

The file /etc/passwd holds local account entries. It does not list accounts supplied through LDAP, Active Directory, FreeIPA, or another external source.

To print the usernames, run:

cut -d: -f1 /etc/passwd

To see complete records, including numeric IDs and home directories, run:

cat /etc/passwd

Each entry has seven colon-separated fields:

username:x:UID:GID:comment:home-directory:login-shell
FieldNameMeaning
1UsernameLocal account name
2Password fieldOften x, indicating separate shadow password storage
3UIDNumeric user ID. UID 0 conventionally identifies root
4GIDPrimary group ID
5GECOSComment or descriptive information
6Home directoryAssigned directory path
7Login shellProgram assigned as the account's shell

The Linux passwd(5) manual defines this record format.

Passwd field layout

A home directory can exist for a username that is absent from the local passwd file, since directory accounts are maintained elsewhere.

In July 2023, an r/linux4noobs poster wrote: “So I am trying to find a user in the /etc/passwd file, but it appears to be missing.”

List accounts available through NSS with getent

Linux NSS lookup

getent passwd lists the entries from the NSS passwd database that its sources can enumerate.

getent passwd

Name Service Switch (NSS) decides which sources Linux asks for account data. The passwd database can use local files, directory services, or other providers. On some hosts, /etc/nsswitch.conf lists sources such as files and sss.

To print only the usernames, extract the first field:

getent passwd | cut -d: -f1
NSS username listing

A provider can resolve a username when you ask for it directly and still decline to enumerate its whole directory. The Linux getent(1) manual documents that enumeration is not always supported.

Find regular users and distinguish system accounts

Linux account categories

Linux uses accounts for services and administrative functions as well as ordinary logins. The util-linux lslogins utility sorts them into conventional categories.

lslogins -u
lslogins -s

-u selects regular users, and -s selects system accounts. Both rely on UID conventions and configured ranges, not on who actually uses the account.

To read the local range settings, run:

grep -E '^(UID_MIN|UID_MAX|SYS_UID_MIN|SYS_UID_MAX)[[:space:]]' /etc/login.defs

UID_MIN and UID_MAX define the range for creating regular accounts. SYS_UID_MIN and SYS_UID_MAX define the system-account range for the tools that use it.

In an isolated Debian 13 container on October 25, 2026, lslogins -u listed root and an account with UID 1000. That container's /etc/login.defs contained UID_MIN=1000 and UID_MAX=60000.

Configured UID ranges

Don't reset or unlock a service account just because it shows up in the list.

Check one username

Linux identity lookup

If you know the username, query it directly.

getent passwd USER
id USER

Replace USER with the username. getent passwd USER asks NSS for its passwd record. id USER reports the UID and groups for that user.

Read the exit status

The getent manual documents exit status 2 for a requested key that was not found and status 3 for unsupported database enumeration. Right after the lookup, run echo $? to print its exit status:

getent passwd USER
echo $?
Getent lookup status

In a Debian 13 container check, getent passwd root returned status 0, and a deliberately nonexistent username returned 2.

When the name resolves but login fails

Finding a user, checking credentials and allowing the login are three separate steps. SSH settings, authentication methods, PAM and access policy decide whether a user who resolves can connect.

In October 2024, an r/redhat poster working with SSSD wrote: “The problem is when I try to login via ssh or sftp.”

Locking a password with passwd blocks password authentication only. Other methods, including SSH public-key authentication, can stay available.

Why a domain user can be missing from getent passwd

SSSD directory enumeration

On a system that uses SSSD, a directory user can resolve by name and still be missing from plain getent passwd. SSSD's enumerate setting defaults to FALSE, so full enumeration is off unless someone turns it on.

First, check which sources NSS uses for passwd:

grep '^passwd:' /etc/nsswitch.conf

A line with files and sss means the host consults those sources. It shows configuration only and does not test directory connectivity.

NSS provider configuration

In January 2026, an r/linux4noobs poster working with Samba and LDAP wrote: “One of my first reflex was to check the users on the system with getent passwd but no user appeared at all, not even tomato even though i can log in with it.” Run a lookup by name to separate “not listed” from “not found”.

Read both results together

Observed resultWhat it meansNext investigation
Absent from plain getent passwd, found by nameEnumeration is disabled or incomplete while lookup by name worksReview the provider's enumeration behavior
Absent from plain getent passwd and from the lookup by nameThe host did not resolve that user in either checkInvestigate NSS and the provider's user resolution
Name resolves but SSH or SFTP failsThe lookup worked. Login policy is a separate issueCheck authentication and authorization controls
Directory identity diagnostics

The SSSD configuration manual lists a cost for full enumeration: more directory queries, more caching load, and more processing overhead. Don't change a production service just to get a longer user list.

If a directory user still does not resolve, follow the provider's troubleshooting procedure or contact the administrator of that directory. Bring the output of getent passwd USER and your NSS source line with you.

Show users who are logged in right now

Linux login sessions

An empty result is normal on a host with configured accounts.

who                  # recorded login sessions
w                    # sessions with added context
loginctl list-users  # systemd-logind view, on hosts that support it
NoScript Team