How to list users and groups on Ubuntu Linux?

Discover how to list users and groups on Ubuntu Linux effortlessly! Follow the simple steps in our guide for easy navigation and efficient management. Start now!

Updated: 17 Dec, 23 by Susith Nonis 6 Min

List of content you will read in this article:

Linux Operating System and its distributions are among the most efficient operating systems that provide a comfortable environment and useful features, which all local users and administrators can easily interact with. In this article, we will talk about how to list users in Ubuntu Linux and explain the different ways to do this. Keep along with us!

Linux and its distros, such as Ubuntu, are among the most popular operating systems developers often use as a team. Explore Ubuntu’s advantages: Understand the advantages and strengths of using Ubuntu.

In this system, different tasks are assigned to users, and each is added or removed from different groups depending on the necessity.  Therefore, the administrator or root user should be able to control the system and access a full list of the existing users and groups for many security reasons. This way, the root user will be ensured that they have been deleted or added correct users and given the right permissions or the proper restrictions.

On Ubuntu Linux, all of the users’ information is registered in a “passwd” file, which is located at “etc/passwd”.  To list the users on your Linux system, you should access the content of this file by following these steps:

  • Press Ctrl + Alt + T to open the terminal.
  • To access the contents of the etc/passwd/file you can use the “cat” command. Otherwise, you can navigate the list using the “more” or “less” commands.  

$ cat /etc/passwd 

$ less /etc/passwd 

$ more /etc/passwd

Executing these commands is one of the best ways to display the list of current users, whether they have recently been connected to the system.

The output would be something like this:

Here, each line is related to a specific user. Therefore, the number of lines represents the number of registered users in the system.  Learn the art of user listing in Linux: Explore our detailed walkthrough for seamlessly listing users on your Linux system.

In the etc/passwd/file, each line contains different fields separated by a colon. Every field includes useful information about each user. They are as follows:

  • Root: Username
  • X: Encrypted password, which can be found in “etc/shadow/file”
  • 0: User identification number (UID)
  • 0: Group identification number (GID)
  • Root: Comment
  • /root: Home directory
  • /bin/bash: Shell used
    1. List users using “cut”

As you can see above, to list usernames on Ubuntu, you can use “cat” command. In case you want to separate usernames, which are available in the first column, you can pipe the “cat” command using “cut” and “d” options. Explore our comprehensive Basic Linux Commands Cheat Sheet for practical examples!

This way, you can see the usernames defined by you through the desired pattern on the passwd columns.

$ cat /etc/passwd | cut -d: -f1

  1. list users using “awk”

The “awk” or “mawk” is the same as “cut” and helps you to pipe the “cat” command and separate users. 

Remember, “awk” is a programming language designed to ease the process of data extraction and managing data streams, and it only displays the user name without any additional information. 

You can use “awk” whenever you encounter complicated text structures, which a single command can roughly isolate.

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

The “getent” command helps you easily collect administrative database entries, which are set in the “etc/nsswitch.conf f/” file, and list users and groups if required.

 getent passwd <optional_user>

This way, you can retrieve all the entries from databases such as LDAP, DVS server, files, etc. 

$ getent passwd | cut -d: -f1

You can also use the “awk” parameter along with the “getent” to display the first field as follows:

$ getent passwd | awk -F: '{print $1}'

Alternatively, you can use the “cut” command to display the same output:

$ getent passwd | cut -d: -f1

You can also check out the existing user on your Ubuntu Linux system using the “getent” command along with the “grep” as follows:

$ getent passwd | grep user-name

For example, suppose you want to search for the username "samreena" and see if such a user exists in the system.

$ getent passwd | grep samreena

You can find out the desired user without using the “grep” command:

$ getent passwd samreena

If you want to know the number of users in your Ubuntu system, you can use the following command:

$ getent passwd | wc –l

To list active or logged-in users, you can type the “w” letter in your terminal. The output would be something like this:


The “w” command not only displays the list of active users but also represents additional information such as login time, remote host, and idle time. Each part of the above result means:

  • User: username
  • TTY: terminal name
  • From: the name of the remote host
  • Login@: login time
  • Idle: idle time
  • JCPU: the amount of time used by processes attached to the TTY.
  • PCPU: the time used by the process displayed in the WHAT field.
  • WHAT: current process of the user.

You can also use the “who” command to check the logged-in users' list. However, the output would not be as detailed as the previous one. 

Here, you learned about different commands that help you to list users and groups on your Ubuntu system. This is one of the best ways to monitor every logged-in user and run the team-based projects as functionally as possible. Let us know if you have any questions or suggestions in the comment section! Good luck!

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.