Linux → List Users

How to list users in Linux

If you’re managing a Linux system, knowing who has access—and who’s currently logged in—can be critical. Whether you’re checking for old accounts, auditing permissions, or debugging an issue, listing users is a quick and easy process if you know the right commands.

Let’s walk through the most useful ways to list users in Linux, from built-in system files to filtered commands for cleaner results.

View all users with /etc/passwd

The /etc/passwd file is the classic source for listing user accounts. Every user—system or human—has an entry in this file unless your system uses external authentication like LDAP.

To see the full list of users, run:

cat /etc/passwd

Each line in the output represents one user and contains several colon-separated fields:

Example:

jdoe:x:1001:1001:John Doe:/home/jdoe:/bin/bash

This method includes both regular users and system/service accounts, which can make it harder to isolate just human users.

Use getent passwd for a database-aware approach

For systems connected to centralized user directories (like LDAP or NIS), getent is the preferred method.

getent passwd

This command queries the system’s Name Service Switch (NSS) configuration and returns all user accounts—both local and remote.

The output format is identical to /etc/passwd, but it pulls from multiple sources depending on how your system is configured. If you’re working in an enterprise environment, this will often be the most accurate list of valid user accounts.

Extract just usernames with awk or cut

If you just need a simple list of usernames without all the extra fields, you can extract that data cleanly using awk or cut.

Using awk:

cat /etc/passwd | awk -F: ‘{print $1}’

Using cut:

cut -d: -f1 /etc/passwd

These commands isolate the first field (the username) by using the colon as a delimiter. You’ll get output like this:

root
daemon
jdoe
nginx

Pair this with other filters (like UID ranges) to exclude system users.

Check who is currently logged in

To list users who are currently logged into the system, use either the who or w command.

The who command shows active sessions:

who

Output:

jdoe     tty1         2025-07-03 08:23

The w command adds information about what each user is doing:

w

Output:

08:35:42 up 2 days,  1:17,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jdoe     tty1     :0               08:23    1:00m  0.03s  0.03s -bash

These tools are great for live session monitoring and system audits.

Use compgen for listing usernames on Bash systems

Another lesser-known method is the compgen command, which is part of Bash’s built-in functionality. This command is especially useful in scripts.

compgen -u

This will quickly output a list of all usernames available on the system:

root
daemon
jdoe

It’s fast, script-friendly, and doesn’t require parsing files manually.

How to list only real (non-system) users

To filter out service and system users, you can list users by their UID (user ID). On most Linux distros, regular users start at UID 1000.

Here’s how to show only human users:

awk -F: ‘$3 >= 1000 && $3 < 65534 {print $1}’ /etc/passwd

This will skip system accounts like daemon, nobody, or sshd, leaving you with:

jdoe
alex
maria

If your system uses a different UID range for human users, adjust the numbers accordingly.

FAQ: user listing basics in Linux

You can list all user accounts by running cat /etc/passwd, getent passwd, or compgen -u. Each method pulls from slightly different sources depending on how your system is set up.

Open your terminal and run:

cut -d: -f1 /etc/passwd

This gives you just the usernames. You can also use compgen -u for a cleaner list on Bash systems.

Use:

cat /etc/passwd

Each line includes the username, UID, GID, home directory, and default shell. To see current session details, use who or w.

Rocky Linux FAQ

How can I check the Rocky Linux version?

You can easily check the version of Rocky Linux by opening a terminal and typing the command cat /etc/os-release. This command will display relevant information, including the version number of your Rocky Linux installation.

How do I download Rocky Linux?

The official website offers ISO images for download. To get started, visit the Rocky Linux download page, select the version you require, and follow the instructions provided.

Is Rocky Linux the same as CentOS?

Rocky Linux is both similar to and different from CentOS. It was created specifically as a response to the discontinuation of CentOS as a stable release, aiming to provide a comparable experience and compatibility for users who previously relied on CentOS.

Is Rocky Linux based on Debian?

No, Rocky Linux is not based on Debian. It is a fork of CentOS, which itself is derived from Red Hat Enterprise Linux (RHEL). Therefore, while both Rocky Linux and Debian are recognized as Linux distributions, they possess different underlying architectures and package management systems.

Additional resources

What is Linux? →

A beginner’s guide to Linux, pros and cons, popular distributions, and more

How to use Linux installation commands →

An overview of how the command line operates on a RedHat or CentOS-based Linux distro—or even within a server cluster

VPS vs dedicated servers →

Similarities and differences, advantages and challenges, so you can decide what you need