How to List users in Linux? [Linux List Users]

As you know that there are commands for creating users and deleting users. How to check logged-in users do you what which commands are used to list users in Linux? That is popularly known as Linux List Users commands. Let's discuss it more.

Updated: 05 Mar, 23 by Susith Nonis 6 Min

List of content you will read in this article:

Linux supports multiple users; thus, sometimes, it becomes necessary to keep track of all the users and groups available on the system. Therefore, the system administrator must ensure complete security so no user can violate the system’s security by running unauthorized commands or access. 

Not all the users on the system have the same rights. These users are specified within different groups based on their level of privileges. Some users are dedicated to running critical tasks, while some have only read access. All this is necessary to keep the system and data security. Thus, the system administrator must know how to take out the system users' list.

In this article, we will explore various ways to look at the list of all the users by executing multiple Linux commands or Linux list users commands that the user can run with proper access.

Linux contains some files that store information about all the users. The file is “/etc/passwd” which keeps the currently available users on the system. To look at the information in the file, you can execute the cat command, “more”, or “less” commands per your requirement.

$ cat /etc/passwd
$ less /etc/passwd
$ more /etc/passwd

In the above output, you can see various columns containing different information about the user. Let’s take a look to understand what this output means. 


We will specify the details in the given order.

As you can see, the password is specified as “x,” which means the password is stored in the encrypted form so that no one can misuse the user’s account. 

1. List Linux users by using the CUT command

If you only want to display the usernames from the ‘/etc/passwd” file, you can pipe the cat command’s output to the “cut” command, as shown below.

cat /etc/passwd | cut -d: -f1

The “cut” command used the “:” as the separator. You print all users’ lists, then pipe to the cut command as per the above command. Then we will only get the first column of the result, which is the usernames from the passwd file, as shown below.

2. Linux users list by using “awk” command

Another way to display all the lists with only the usernames is to execute the cat command and pipe the output to the “awk” command, which works almost similarly to the “cut” command. The awk command is an interpreter for the AWK programming language that helps extract and manipulate the data streams. It makes it easier to execute even the complex commands that any other command cannot do.

The example below shows how the “awk” command works and displays the output.

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

3. List Users in Linux by Using getent command

One of the simple ways to list all the Linux users is to hit the “getent” command along with the “passwd” argument and an optional user you want to list on your system, as shown below.

getent passwd <optional_user>

The getent command takes all its entries from Name Service Switch databases such as LDAP, DNS server, etc. all the details regarding these data sources are present in the config file- nsswitch.conf, which is located under the /etc. Folder.

getent passwd

getent passwd | cut -d: -f1

getent passwd |awk -F: ‘{print $1}’

4. Listing all the connected users on the Linux host

The “cat” command on the “passwd” file will not display all the connected users on the Linux host. You need to execute the “who” or “users” command.




The above two commands will list only the connected users on the system when executing the command.

5. Using “/etc/group” for listing the groups on Linux

Other than listing users, Linux allows you to list all the groups available on the system. All the group details are stirred in the file- /etc/group. You can execute the “cat”, “less”, or” more” commands on this file to display its content.

cat /etc/group

less /etc/group

more /etc/group

In the above output, you can see some details, and we will explain the meaning of different columns of the /etc/group file.



  • The root is the group name.
  • x is the password in the encrypted form
  • 0 is the GID (group ID)
  • The root is the user present in the group.

6. Linux group list Using the “cat” command

As you can see in the above example, the details are too cumbersome. So to only get the details of the groups, you can use the cat command on the “/etc/group” file and pipe the output to the “cut” command as we did with the “passwd” file, as shown below.

cat /etc/group | cut -d: -f1

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

7. Group list in Linux by getent command

You can use the following syntax of the “getent” command to display the group list.

$ getent <database> <key>

Here, the database is the group, and the key is optional. But if you do not provide any value for the parameter key, you will get the details of the complete group file.

getent group

To the details of one specific group, you can specify it as shown below.

getent group root

For every Linux system administrator, it is essential to know its users and their access to the system. For that knowing the users is necessary from a security point of view. To get the user’s details, Linux offers various simple commands. We have mentioned some of the commands in this article and how they work with different arguments.

Try this Linux commands yourself and understand the working of Linux list users.

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.