How to List Users on Debian 12

Users are created on Debian to manage the computer. Some of these users are granted sudo privileges to perform the root user tasks. It helps the enterprise to manage their tasks by dividing them among these users. 

To add new users and delete them, follow the instructions and use the comamnds explained in the post. However, sometimes it is required to list down the users on Debian to find out the number of users as well as the groups that are assigned to the users. 

This post will explain the methods of listing down the users on Debian using the terminal as well as using the graphical user interface. 

The outline of the article is as mentioned below:

  1. What are Various Types of Users on Debian
  2. What are the Methods to List Down the Users on Debian
  3. Method 1: List the Users on Debian by Accessing the /etc/passwd File
  4. Method 2: List the Users on Debian by Using the getent Command
  5. Method 3: List the Users on Debian by Using the users Command
  6. Method 4: List the Users on Debian by Using the Settings Menu
  7. How to Find Out the Status of the User Account on Debian
  8. How to Find the Count of the Number of Users on Debian

What are the Various Types of Users on Debian?

There are two various types of users on Debian which are known as the system users and normal users. 

The system creates the system users during the installation of the Debian to run the processes running in the background. One of the known system users is the root user that has the right to perform the administrative tasks on Debian. 

The second one is the normal users that are created by human beings to manage different tasks of the computer. These users have their own unique passwords and home directories. 

What are the Methods to List Down the Users on Debian?

Different methods to list down the users on Debian are explained in the next section. 

Method 1: List the Users on Debian by Accessing the /etc/passwd File

Every user has its unique password, therefore, all the Debian users are included in the /etc/passwd file.

This file can be accessed in different ways and some of them are explained in this section. 

List the Contents of /etc/passwd File Using the cat Command

The cat command is used to display the contents of the file in the terminal and to use it for displaying the users included in the /etc/passwd file, run the command:

$ sudo cat /etc/passwd

The users have been displayed on the screen and are marked on the above figure. 

List the Contents of /etc/passwd File Using the Pagers

Pagers are also known as terminal pagers and are used to display the file’s content in the form of pages. This means the scroller can be used to display the next page of the file in the terminal. 

In Debian, different commands display the output in the form of the pagers such as more and less command utilities. 

These can also be used to list down the contents of the /etc/passwd file by using the commands:

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

The more and less commands are mostly used to open the single page of the file rather than the entire file. 

List the Contents of /etc/passwd File Using the awk Command

The awk command is used to perform the pattern scanning and retrieve the requested information from the file as the output. To display only the names of the users from the /etc/passwd file with the awk command, run the command:

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

Method 2: List the Users on Debian by Using the getent Command

Another command line method to list down all the users on Debian, execute the following getent command:

$ getent passwd

Method 3: List the Users on Debian by Using the users Command

The user command can also used to display the list of the users that are logged in as shown:

$ users

Method 4: List the Users on Debian by Using the Settings Menu

To list down the normal users, open the “Settings” from the “Application’s” menu:

Now click on the “Users” from the left menu of the “Settings”:

The names of the users have been displayed:

How to Find Out the Status of the User Account on Debian?

To find out the status of the user account whether it is being existed or deleted, run the next-mentioned command:

$ getent passwd itslinuxfoss

Replace the “itslinuxfoss” with the username whose status is supposed to be out. 

How to Find the Count of the Number of Users on Debian?

To count the total number of users on Debian, use the compgen command as shown:

$ compgen -u | wc -l

Conclusion

To list down the users on Debian 12, display the contents of the “/etc/passwd” file by using different commands. The getent command, compgen command, and the users command are also used to display the list of users. 

This blog explained different methods for listing down the users on Debian 12 by using the terminal or the graphical user interface methods.