Listing Users in Linux explained with examples

In this tutorial, we shall show you how to list the users, find a specific user, find the total number of users, and more on your Linux system.

Finding out the list of users on a Linux system is a common situation, especially for system administrators. We will show you how to do this in today’s tutorial.

Linux is a multi-user platform. It ensures that multiple users can use it without the need for a new installation. Linux handles applications securely. No user can access other user files without proper authentication access. The list of accounts is shown on the Terminal and helps manage.

Let’s get started.

How to list Users in Linux

There are many ways you can list users in Linux.

1. Using etc/passwd command

One of the easiest ways to access the list of users in Linux is to find that information in the /etc/passwd file. To check its data, you need to use either less or cat.

$ cat /etc/passwd | more

Content of /etc/password

You should see a lot of lines being outputted on the Terminal. Each line is divided into seven fields using a colon delimiter. The sequence of information is as below.

  • User name
  • Encrypted password
  • UID: User ID number
  • GID: User’s group ID number
  • GECOS: User’s full name
  • User home directory
  • Login shell

All this information can be a little overwhelming and unnecessary. That’s why it is always a good idea to use the awk command only to display the username.

To do so, you need to use the following command.

awk - F: '{print $1}' /etc/passwd

Showing only the name using awk command on etc/passwd file

You can also get the same result using the cut command.

cut -d: f1 /etc/passwd

For some reason, if the above command doesn’t work, then you need to use the following.

cut -d: -f 1 etc/passwd

2. Using the Getent command

You can also use getent command to display the list of users. In this case, it queries the passwd database, which is in the list of database configured in /etc/nsswitch.conf.

The command to list all the users using getent command is as below:

getent passwd

You can also use more or less command along with it to limit the output according to your window size.

Showing the list of users using the getent command

The output is precisely similar to the information contained in the etc/passwd file. If you want to access the LDAP database, then you need to provide the user authentication with LDAP.

You can also trim the output of the user’s list using the awk and cut command. The commands are as below for your ready reference.

$ getent passwd | awk -F: '{print $1}'
$ getent passwd | cut - d: - f 1

3. Finding a specific user

Getting a long list of users is not desirable in most cases. What if you want to search for a particular user? It is possible, and here is how.

To do so, you need to use the grep command and pipe it with the getent command.

For example, if we want to search for tuts user, then we can do it using the following command.

getent passwd | grep tuts

Finding a specific user using the grep a getent command

If there is no output, then it means that the user is not registered in the system. There is also a more straightforward command that lets the job done. In this case, you do not need to use the grep command.

getent passwd tuts

If you get a reply, then the user is present; if not, then there is no user with that specific name.

4. The total number of users in the system

If you are curious to know the total number of users in the system, then you can check it using the following command:

getent passwd | wc -l

The total number of users

Here, we used the wc(word count) command to learn about the total number of users.


This leads us to the end of our tutorial on how to list users in Linux. Besides, we also learned how to find a specific user, and also to fish out the total number of users registered on a Linux system. Do you use the commands mentioned above for your daily job? What other tricks do you use? Do share with the rest of the FOSSLinux readers. Sharing is caring!

Divya Kiran Kumar
I'm the Editor of FOSS Linux. I worked as a Software Engineer before taking up blogging as my full-time job. I enjoy using Linux, and can't imagine anything else for my PC. Apart from writing for FOSS Linux, I enjoy reading non-fictional books. Sapiens was my favorite last read. I hope you enjoy reading and using this blog to enhance your Linux experience! Have a great day ahead!


Please enter your comment!
Please enter your name here





EndeavourOS is an extremely recent distro in the Linux space released back in July 2019 as a spiritual successor to Antergos Linux, which was also discontinued in May 2019. In function, it is a rolling release distro based on Arch Linux with a focus on delivering a beginner-friendly pre-configured desktop environment to its users.
If we look at today's market, there are plenty of laptops available from different companies. The laptops differ in various ways, such as specifications, models, functionality, and many more. The common thing about all the laptop regardless of the type and functionality is that they all have operating systems that power the laptops. There are a variety of operating systems, the common ones being Windows, Linux, and macOS.