How to List Users in Linux?

by robin

Linux is a popular open-source operating system widely used by individuals and organizations worldwide. One of the most basic tasks that users of Linux systems need to know is how to list all of the users on a given system popularly known as Linux list users. It can be useful for several purposes, including troubleshooting, security, and management. 

Severally, we will provide a detailed explanation of how to list users in Linux. One of the most powerful features of Linux is its ability to create and manage lists of users. There are several ways to create and manage user lists in Linux. The most common method is through the command line interface (CLI), which allows users to enter commands like linux list usersand manipulate the system in various ways. One of the most basic commands for creating and managing user lists is the “useradd” command, which allows users to add new users to the system.

linux list users

How to List Users in Linux

You can list users in Linux in different ways, but the most common method is to use the “cat” command and the “/etc/passwd” file. The “/etc/passwd” file is a text file that contains information about all of the users on a Linux system. The “cat” command is used to display the contents of this file on the screen.

To linux list users on a Linux system, simply open a terminal window and enter the following command:

Cat /etc/passwd

It will display the contents of the “/etc/passwd” file on the screen. It includes a list of all the users on the system. Each line in the file corresponds to a single user, and colons separate the fields. 

The first field is the username, the second field is the user’s encrypted password, the third field is the user’s numerical user ID, the fourth field is the user’s numerical group ID, the fifth field is the user’s full name, the sixth field is the user’s home directory, and the seventh field is the user’s default shell.

Also Read: How To Use SCP Command for File Transfer in Linux?

Using the Terminal Pagers less and more

When there are many users on the system, limiting the /etc/passwd file output display will be helpful at once. You can use the terminal pager command, like less and more. It will help you browse through the content line by line.

Now, to open /etc/passwd using less use-

Less /etc/passwd

With this, the file’s first page will appear in the output. The list will automatically stop once it reaches the end of the terminal screen.

While the ‘more’ command is a bit older and limits the set of functionalities. To get similar results with more use-

More /etc/passwd

Linux List Users Using the awk Command

Here, if you wish to display only the username, you can use the awk command. It will print only the first field, which will include the username. As the data fields in the/etc/passwd colon separate the command, the following syntax will tell awk to output only the first field in each line.

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

Now, if you wish to combine less and awk page by page to see results, then the syntax will be

$ awk -F: ‘{ print 

$1}’/etc/passwd | less

The linux list users command will help when you wish to write a script that has something to do with a lot of user accounts. When you list the user account names and then redirect them into a text file, then it will help save a lot of time. You just need to copy and paste the rest of the command in each line.

Also Read: How to Extract/ Unzip tar.gz file? – Unzip Command

Using the ‘cut’ Command

cut -d: -f1 /etc/passwd

This command will show only the username of the users. It will help get similar results to the awk command. Here, you need to use the -d option and ask it to choose only the first field using the -f option.

Alternatively, you can also use the ‘getent’ command to list all the users on a Linux system.

getent passwd

Getent command helps search and display the system database entries. This command will show the complete details of the users on the system. You will find the searchable database listed in the /etc/nsswitch.conf file. Here, by default, the files include the passwd database. The output here will be very similar to the one with “less/etc/passwd”. But the command queries the GNU Name Service Switch functionality configuration file.

To get the entire contents of the passwd database, use-

Getent passwd

The output here will be similar to the cat command. You also have the option to use getent to look up specific users which the linux list users command doesn’t offer. For this, you must use.

Getent passwd [username]

The command shows the related passwd entry line if the user is on the system.

Listing Active Users

If you only want to list the users currently logged into the system, you can use the “who” command. This command will show you a list of all the users currently logged in, along with their terminal and login time.

Listing Users in a Group

If you want to linux list users in a specific group, you can use the “getent” command and specify the group name or group ID.

Getent group groupname

Replace the ‘groupname‘ with the name of the group you want to list the users of. It will show the group name, group password, and group members.


How do I add a new user to a Linux system? 

To add a new user to a Linux system, you can use the “useradd” command with the linux list users command. With this, you can create a new user account, set the user’s password, and configure other settings for the new user.

How do I delete a user from a Linux system?

To delete a user from a Linux system, you can use the “userdel” command. This command allows you to delete a user account unpassworded with the user’s home directory and other files associated with the account.

How can I change a user’s password in Linux?

To change a user’s password in Linux, you can use the “passwd” command. User’s password, open a terminal window, and enter the following command: sudo passwd username. Here, “username” is the username of the user whose password you want to change.

How can I check the last time a user logged in to the system?

You can use the “last” command. This linux list users command shows the login history of all users on the system. To check the login history of a specific user, you can use the “last” command with the username as an argument.

How can I check which users can access a specific file or directory?

To check which users have access to a specific file or directory, you can use the “ls” command with the “-l” option. This option shows the permissions of a file or directory in the owner and group of the file and the users who have access to it.


Understanding the basics of user management in Linux is crucial for system administrators and developers who use Linux operating systems. Hence it is very important to learn the linux list users command. Depending on your needs and preferences, there are many ways to list users on a Linux system other than using the linux list user command.

The most common methods are using command line tools such as ‘cat /etc/passwd‘, ‘awk,’ ‘getent passwd‘, and GUI tools such as ‘Users and Groups‘ and ‘System settings.’

You may also like

Leave a Comment