Introduction:
Listing all the system users in Linux is considered a very important task of user management. By performing this task, you can easily know how many users are currently there on your system. With the help of this information, you can easily identify which of these users are legitimate and which users are not needed any longer. By identifying this, you can easily remove all those users that are not needed now so that they are not able to access your system anymore. Therefore, today we will learn all the methods of listing the users in Linux Mint 20. However, the very same methods can also be used on Debian 10 and Ubuntu 20.04.
Methods of Listing Users in Linux Mint 20:
The methods of listing users in Linux Mint 20 can be categorized as the CLI-based methods and the GUI-based methods. Both types of methods have been explained below:
CLI-based Methods:
The two most common CLI-based methods of listing the users in Linux Mint 20 are as follows:
Method # 1: Using the “getent” Command:
The “getent” command is used to list all the users in Linux Mint 20 in the following manner:
getent passwd | awk –F: ‘{ print $1}’
We can also use the simple “getnet passwd” command, however, doing this will display lots of other information too which might not be relevant for you in the given context. That is why we have piped the output of the “getent passwd” command to the “awk” command. This additional command is there to print only the information which is relevant for us i.e. the usernames of all the users.
All the users of our Linux Mint 20 system are shown in the image below. In your case, you can use the scroll bar to view the entire user list.
Method # 2: Using the “/etc/passwd” File:
As the name implies, the “/etc/passwd” file stores the usernames and passwords of all your Linux system users. We can simply view the contents of this file to list down all the users of our Linux Mint 20 system in the following manner:
awk –F: ‘{ print $1}’ /etc/passwd
Again, you can choose to display the entire contents of the “/etc/passwd” file which will essentially contain the following parameters: usernames, passwords (unencrypted since the encrypted passwords in Linux are always stored in the /etc/shadow file), User ID (UID), Group ID (GID), user’s full name, login shell, and user’s home directory. However, for this particular scenario, we are only concerned with the usernames of all the Linux Mint 20 users. That is why we have used the “awk” command instead of the “cat” command for displaying the contents of the “/etc/passwd” file so that we can only get the desired output.
All the users of our Linux Mint 20 system are shown in the image below. In your case, you can use the scroll bar to view the entire user list.
GUI-based Method:
The most popular GUI-based method of listing the users in Linux Mint 20 is as follows:
Method # 3: Using the Users and Groups Utility:
The Users and Groups utility is a built-in utility of Linux-based systems. This utility displays the names of all the users and their groups. We can access it by first clicking on the Mint Menu icon as highlighted below:
After launching the Mint Menu, just type users and groups in the search bar that appears on the screen and click on the Users and Groups search result.
When you will do this, you will be asked to authenticate yourself without which you will not be allowed to access this utility. Just provide your login password and click on the Authenticate button as highlighted in the following image:
As soon as you will authenticate yourself, you will be able to see the Users and Groups window on your screen. In its Users tab, you will see all the usernames as shown in the image below. You can also switch to the Groups tab to see all the user group names. Moreover, you can also add new users or even delete the existing users with the help of this utility.
Conclusion:
If you ever wish to list down all the Linux system users, you can pick any of the three methods that are discussed in this article. We have performed these methods on Linux Mint 20, however, they can also be used on Debian 10 or Ubuntu 20.04 with the very same level of convenience.