How to List Users in Ubuntu 22.04


A Linux administrator manages the user on the system. The roles/authorizations are defined as a single or a group of users. One of the key activities in user management is to keep tracking the number of users. An administrator keeps an eye on the user list to check/differentiate between the system and normal users, delete/remove the user, check/update the group, etc.

In today’s guide, we will elaborate on the methods to list the users on Ubuntu 22.04 with the following supported outline:

Types of Users in Ubuntu/Linux

How to List Users in Ubuntu 22.04?

Method 1: How to List Users Using the /etc/passwd File? | Terminal

Method 2: How to List Users Using Ubuntu Settings? | GUI

How to List Currently Logged-In Users in Ubuntu 22.04?

Bottom Line

Before digging into the methods, let’s differentiate/understand the types of users in Ubuntu/Linux.

Types of Users in Ubuntu/Linux

    • System Users: The users responsible for carrying out backend operations. The root user is a system user. UID (Unique User ID Range) of the system users varies from (0-999). The UID “0” specifically refers to the root user. No logins are set for the system users. Therefore, they are only exercised in a logged-in system.
    • Normal/Regular Users: Normal users are created by the root user (or the normal user can also create a regular user). Normal/Regular users have a UID between 1000 and 4,294,967,295 (the largest 32-bit number).

How to List Users in Ubuntu 22.04?

Ubuntu has competitive support from CLI and GUI. The commands like, cat, getent, awk, or compgen are the renowned utilities to get the users’ list. These commands help in retrieving the users from any user-associated file (thus do not confuse yourself that a simple cat command will list the users).

Method 1: How to List Users Using the /etc/passwd File? | Terminal

The “/etc/passwd” file carries the information of all the user’s accounts on Ubuntu/Linux. The “/etc/passwd” file is accessed using the “cat” command with less/more/awk/grep (you can use it as per your requirement to get the content of “/etc/passwd”).

Method 1.1: Using cat /etc/passwd | List All Users With Details

The command fetches the data from the “/etc/passwd” and prints it on the terminal (no filter is used yet):


Detailed Output of the Command

The output comprises the seven fields in total (separated by colons), where:

The first field shows the name of the user, the second represents the password (encrypted), the third/fourth is dedicated to the UID/GID, and the fifth shows the GECOS (the field refers to the additional information of the user). The sixth and seventh fields represent the home directory of the user and its shell respectively.

How to Differentiate Between the System and the Normal Users on Ubuntu 22.04?

If you look at the output of the “cat /etc/passwd” command, the third column actually denotes the UIDs (User IDs), as highlighted in the image below. The users having IDs 0000-999 are the system users and the rest of the IDs represent the normal/regular users.

Method 1.2: Using awk With /etc/passwd | List the Usernames Only

Use the awk command (to retrieve the first column only) with the cat /etc/passwd to get the user names only:

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

Note: Alternatively, use the “cat /etc/passwd | cut -d: -f1” command also represents the list of users from the file “/etc/passwd”.

  • Get the Number of Users

Use the pipe operator with the “list of usernames only” and the wc command. The users are retrieved using the awk command and the list is then passed to the “wc” command to count the users:

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

Method 1.3: Use the getent passwd Command

The getent command when used with the passwd keyword accesses/retrieves the data from “/etc/passwd”. Let’s see how it differs:


Same output as “sudo cat /etc/passwd”, where the first column represents the usernames.

  • List Only Targeted Users

The “getent passwd” command allows you to enter a specific range of user IDs to get a targeted list of users, i.e., normal/regular users and system users.

  • For Normal/Regular Users

The below command fetches only normal users (first five ranging from 1000 to 1005) from the “/etc/passwd” list. The upper limit could be any number greater than 1000 up to the largest 32-bit () number.

$ getent passwd {1000..1005}

  • For System Users

If you enter the range {0000..999} in the “getent passwd” command, all the system users will be printed:

$ getent passwd {0000..999}

Note: To filter/refine the output of the “/etc/passwd” file, the users can utilize “less” (one page per screen/output), “head” (get the top 10 entries of the file), or “tail” (fetch the last 10 entries) commands.

Method 1.4: compgen -u Command

The “compgen -u” command fetches the users from the “/etc/passwd” file and lists all the usernames only, as follows:


Method 2: How to List Users Using Ubuntu Settings? | GUI

The Ubuntu settings application has a separate “Users” management section to manage the normal/regular users on Ubuntu. There is a list of users as well. Let’s check it how to get into it:

Open the “Users” section inside the “Ubuntu Settings” and the user’s accounts are displayed, as shown below:

How to List Currently Logged-In Users in Ubuntu 22.04?

Ubuntu/Linux records the list of logged-in users in a session. You log in with one user and then switch to other users. Ubuntu puts them in the list of currently logged-in users.

who Command

Use the who command which lists the logged-in users, the login time, and the login terminal:


Users Command

The “users” command which shows only the names of the logged-in users:


w Command

The “w” command also lists the logged-in users alongside the login time/shell information:


Bottom Line

In Ubuntu/Linux, listing the users is carried out by the administrator to manage the overall operations performed (or to be performed) by the users. The user-related details are stored in the “/etc/passwd” file which can be accessed from the terminal using commands. The UID ranges from {0000..999} refers to the system users whereas the greater than 1000 UIDs represent the regular users.

Apart from only the command line, the user’s list can be found in the Ubuntu settings. This post has briefly demonstrated the methods to list users in Ubuntu 22.04.

Print Friendly, PDF & Email
Categories