shumail shabeeh shaheeh
January 21, 2024

How to List Linux Users on Ubuntu – Ubuntu list Users Guide

Embrace Love: Share Us on Social Media
How to List Linux Users on Ubuntu - Ubuntu list Users Guide

Ubuntu, a popular Linux distribution, provides powerful tools for managing user accounts and accessing detailed information about users on a system. Whether you’re an administrator or an individual user, having a comprehensive understanding of user accounts is crucial for effective system administration. In this guide, we’ll explore various commands and methods to list users on Ubuntu. Most of the Ubuntu list users command is used as cat command in the /etc/passwd.

1. Exploring the /etc/passwd File

The primary and reliable method to list users is by examining the contents of the /etc/passwd file. This file encapsulates essential user details such as usernames, user IDs, group IDs, home directories, and login shells.

cat /etc/passwd

ubuntu list users

This command provides a comprehensive view of all users and their associated information.

2. Using getent for Database Queries | Ubuntu list users

The getent command proves to be a versatile tool for querying databases, including user information. To list all users, utilize getent with the passwd database.

getent passwd

getent passwd

This command mirrors the information stored in the /etc/passwd file.

3. Parsing Output with cut and awk

To extract specific user details from the /etc/passwd file, you can use cut or awk commands. These commands enable you to focus on relevant information, such as usernames.

cut -d: -f1 /etc/passwd


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

Both commands yield a concise list of usernames.

4. Filtering Users by UID

Distinguishing between system and normal users involves checking the User ID (UID). System users typically have a UID less than the specified minimum, while regular users fall within a specific UID range.

grep -E '^UID_MIN|^UID_MAX' /etc/login.defs

This command helps identify the UID range for regular users.

5. Utilizing compgen for User Lists

The compgen command simplifies the process of generating user lists based on system components, providing a quick overview of all users.

compgen -u

This command generates a user list without additional details.

6. Checking User Existence

To determine if a specific user exists on the system, you can filter the user list using the grep command.

getent passwd | grep user_name

This command confirms the existence of a user.

7. Listing Normal Users for Scripting

For scripting purposes, you may want to list only normal users. This involves extracting users with UID values within a specific range.

eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1

This command extracts usernames within the UID range suitable for scripting.

8. Displaying Currently Logged-In Users

To identify users actively logged into the system, commands like who and users provide real-time information.




These commands display details about currently logged-in users.


How can I list all users on my Ubuntu system?

You can list all users on your Ubuntu system by examining the contents of the /etc/passwd file. Use the command cat /etc/passwd to display detailed information about each user.

What information does the /etc/passwd file contain about users?

The /etc/passwd file contains crucial information about users, including their usernames, user IDs (UID), group IDs (GID), home directories, login shells, and more.

Are all users listed in the /etc/passwd file created by me?

No, not all users listed in the /etc/passwd file are created manually. Many users are created automatically during the installation of the Linux system or as part of the configuration process for specific software applications.

How can I distinguish between system users and normal users?

System users typically have a User ID (UID) less than the specified minimum, while regular users have UID values within a specific range. You can use the grep -E '^UID_MIN|^UID_MAX' /etc/login.defs command to determine the UID range for regular users.

How do I check if a specific user exists on my Ubuntu system?

To check if a user exists, you can use the getent passwd | grep user_name command. If the result shows user details, the user exists; otherwise, it does not.


In conclusion, mastering the various methods to list users on Ubuntu is an essential skill for system administrators and users alike. Whether you’re managing accounts, writing scripts, or monitoring system activity, these commands offer valuable insights into the user landscape of your Ubuntu system.

Follow CyberHosting on Facebook Twitter Linkedin for updates.

If you want to get rid of the hosting and server issues checkout our plans in the USA. Other plans are also available in our pricing page.

Stay in the loop!

If you found this article helpful, join our mailing list to receive CyberHosting updates and latest news from the LiteSpeed community.

  • Only useful information.
  • Relevent to hosting and LiteSpeed.
  • No spam. Ever.

By joining our mailing list you agree to receive periodic communications from CyberHosting. You can unsubscribe from within our emails any time.