How to List All Users in Linux
As a system administrator or a user of Linux, you might need to view the list of users on your system. The good news is that it is an easy task and can be achieved using simple commands. In this article, we will guide you through the steps to list all users in Linux.
Using the Command Line Interface (CLI)
The most standard method to list all users on Linux is through the Command Line Interface (CLI). Here, we can use either the “getent” command or “/etc/passwd” file to display a list of users.
Using “getent” command
The getent command retrieves entries from the admin databases, and it’s mostly used to retrieve information about users and groups. To list all users using “getent,” open your terminal and enter the command below:
getent passwd
After typing this command, you’ll see a list of users that exist on your system. Each entry in the list describes the user in the following format:
username:password:UID:GID:GECOS:home directory:shell
Here’s what each field means:
– Username: The username of the user account created on the system.
– Password: The user’s password, encrypted.
– UID: The User IDentifier (UID) is a unique numerical value assigned to each user account.
– GID: The Group IDentifier (GID) specifies the primary group of the user.
– GECOS: This is a field reserved for additional information like the user’s full name, address, phone number.
– Home directory: This is the full path pointing to the user’s home directory when a user logs in.
– Shell: This is the default shell assigned to a user when they log in.
Using “/etc/passwd” file
The “/etc/passwd” file contains user account information, including usernames, passwords, and home directories, and can be used to show all the users on the system. To display the user list using the “/etc/passwd” file, run this command:
cat /etc/passwd
The output you get is almost the same as the previous command. The difference is only that each line of the output started with a username.
Using Graphical User Interface (GUI)
If you’re more comfortable with a Graphical User Interface (GUI) than the command line, you can use the System Settings tool to display the list of users on your Linux system.
Here’s how to do it:
– Open the System Settings from the application launcher.
– Under the “User Accounts” tab, you will see a list of users on the system. Each user shows their username and an icon, which provides additional information.
Conclusion
That’s everything you need to know about listing all users in Linux. Remember that the “getent” command and “/etc/passwd” file are always available on Linux systems, whether you’re using a command-line interface or GUI. The choice is yours depending on your preference or the system you’re working on.