How to list users in Linux

A close up photo of a person's hands typing on a laptop keyboard
(Image credit: Shutterstock)

Ever wondered who's on your Linux system? Whether you're a tech pro or just getting started, knowing how to find the list of users is a handy skill. This guide is here to walk you through the simple steps of getting a user list on Linux.

In this how-to guide, we'll cover some basic commands for discovering usernames, user IDs, and more. It's not just about who's who but understanding what's going on behind the scenes in your Linux system.

Whether you're keen on tightening security, fixing problems, or just curious about your Linux setup, this tutorial shares the Linux commands that will produce the information you're looking for.

How to list users in Linux

You'll need to access your Linux command line interface in order to complete the following steps. It would be helpful if you also have a basic understanding of Linux commands, but it's not absolutely necessary.

1. Produce full list of users

(Image: © Future)

The easiest way to obtain a list of users in Linux is to use the getent command.

The getent command retrieves information from Linux's databases, including information about users.

To obtain a full list of users, open your system's command line interface and type the following command: getent passwd

This produces a list of users on the system and also includes (in a very abbreviated format) details about the user ID, group ID, user's home folder, default shell, optional personal information, and whether the user has a password.

2. Produce list of user first names only

(Image: © Future)

To produce a simpler user list, enter the command getent passwd | awk -F: '{ print $1}'

The awk tool is a versatile text processing tool in Linux and is mainly used for pattern scanning and processing.

By specifying print $1, we are instructing Linux to only return the first field of each entry.

The result is a list of first names only without all the additional information we got with the previous command.

However, you'll notice in the example above, that there are many entries like systemd-network and systemd-timestamp which is probably not what you're looking for when you're trying to produce a list of users on the system.

This is because Linux does not distinguish between human users and system accounts created by applications.

We will look at producing a list of just the human users in the next couple of steps.

3. Understanding User Identifiers

(Image: © Future)

Users on the system are given a user identification number known as a UID. We can use this number to separate human and non-human users.

Enter the command grep -E '^UID_MIN|^UID_MAX' /etc/login.defs to return the range of user identification numbers used by human users.

As you can see in the screenshot above, human users on my system have UIDs that are between 1000 and 60,000.

4. Producing a list of human users only

(Image: © Future)

Now, you need to run the command to get a list of human users. Based on the answer I was given in the previous step, my command was getent passwd {1000..60000}.

You'll need to ensure that the numbers in curly brackets in your command reflect the minimum and maximum UIDs you were provided with.

In my example above, I had a list of four people once I had removed all the non-human application and system users.

The getent command is just one of the ways that you can obtain information about users. If you are looking for specific user information, you might want to tailor your command to produce a filtered list that matches your requirements. Filtering or shortening your results is especially helpful if you have a large number of users on your system.

Producing a list of users in Linux can be beneficial for several reasons, including helping administrators identify who has accounts on the system or identifying which users own specific files or processes. Understanding Linux commands means that you can access information whenever you need it in the way that best suits you.


For more help with Linux, check out our guides on how to find CPU information in Linux, how to add users in Linux and how to find a file in Linux.

Emma Street
Contributor

Emma Street is a freelance content writer who contributes technology and finance articles to a range of websites, including Tom's Guide, Top10.com, and BestMoney. She has over 15 years of experience working in technical development within the fintech industry. When not writing about tech, Emma can be found writing romantic fiction, reviewing films, and updating her tea blog.

Read more
Cartoon of person peering through US flag
Western governments want your data and big tech is happy to provide – how to slow them down
A Windows 11 laptop, demonstrating how to use Windows 11 Voice Access
How to use Windows 11 Voice Access: Tell your PC what to do
Google Chrome on Android
How to stop your personal data from appearing in Google searches
Facebook, Instagram, YouTube, Pinterest, X, LinkedIn, Reddit, TikTok, Threads apps on an iPhone
Why you need to review your app permissions now
How to Set up a VPN
How to set up a VPN on any device
MacBook Pro M3 Pro on bench
Your Mac has a built-in screen recorder — here's how to use it
Latest in Operating Systems
Google Chrome
Chrome failed to install on Windows PCs, but Google has issued a fix — here's what happened
Mac Studio on a desk hooked up to a Studio DIsplay
Mac Studio M3 Ultra: 3 reasons to buy and 2 reasons to skip
Microsoft Office is finally as it should have been on iPad
Microsoft tests free Word, PowerPoint and Excel apps for Windows — expect a lot of ads
laptop anger
Latest Windows 11 update reportedly breaking major parts of the operating system
Windows 10 logo
Windows 10 end of life set for this year — everything you need to know to get ready
Windows 11 logo on a laptop screen
I reviewed Windows 11, and these are the 5 new features I'm most excited about for 2025
Latest in How To
avoid AI scams
How to spot AI-generated fake products when shopping online
An image of an iPhone screen showing the Safari app icon in the center
I got tired of Safari revealing my web searches in iOS 18.4 — this setting fixes that
Gmail logo on iPhone
I used Google Gemini to declutter my Gmail account — here's how you can do it too
An Amazon Echo speaker with ChatGPT logo next to it
I replaced Alexa with ChatGPT on my Amazon Echo — here's how you can do it too
AirPods Pro 2 in hand
Your earbuds are disgusting — here's the right way to clean them
ChatGPT logo on a smartphone screen being held outside
7 biggest ChatGPT mistakes — and how to fix them