Listing Users in Linux - How to do it ?

A system user is the one that creates normal users. 

Therefore, in this instance, the system user is the root. This user is created when you first install the Linux operating system. Additionally, you can create system users for particular applications.

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.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Linux related tasks.

In this context, we shall look methods of listing the users in Linux Mint 20. 


How to list 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.

Note that the same methods can also be used on Debian 10 and Ubuntu 20.04.


1. Listing Users in Linux Mint via CLI-based Methods

The two most common CLI-based methods of listing the users in Linux Mint 20 are as follows:

i. Via 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.


ii. Via 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.


2. Listing Users in Linux Mint via GUI-based Method

The most popular GUI-based method of listing the users in Linux Mint 20 is as follows:

Via 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.

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 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.

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.


[Need urgent assistance in fixing missing Linux packages? We are available to help you today. ]

This article will guide you on the different methods to list down all the Linux system users. To know whether a particular user is having sudo access or not, we can use -l and -U options together. For example, If the user has sudo access, it will print the level of #sudo access for that particular user. 

If the user don't have sudo access, it will print that user is not allowed to run sudo on localhost.

To change users in #Linux:

The su command lets you switch the current user to any other user. 

If you need to run a command as a different (non-root) user, use the –l [username] option to specify the user account. 

Additionally, su can also be used to change to a different shell interpreter on the fly.

Related Posts