On most Linux systems, including Ubuntu, there’s not a single program or tool to list all user accounts on the system. If you’re using the desktop GUI, you may be able to see all the user accounts as an administrator. Since there is no single tool to list users, we usually depend on system files to list the users. All system accounts created are stored in multiple files on the server, and by listing the content of these files, we can find out the list of users and groups. Again, there are multiple ways to find out user accounts on Ubuntu. Below are commands that when used, show you all user accounts on Ubuntu and other Linux systems.

List User in the passwd file

One popular option for listing user accounts on Ubuntu is to view the content of the /etc/passwd file. This file stores local user account information from the login name to the encrypted password and account ID. So, to view all user accounts on the system run the commands below: When running the commands above, it should list the content of the /etc/passwd file. In there you’ll see all the accounts created on the server. You can also use the cat /etc/passwd command to output the same list. For students and new users, this can be confusing if they don’t know how to read the content of the file. However, each line in the file is a single account identity. there are seven fields delimited by colons that contain the following:

User name Encrypted password (x means that the password is stored in the /etc/shadow file) User ID number (UID) User’s group ID number (GID) Full name of the user (GECOS) User home directory Login shell (defaults to /bin/bash)

Now, if you just want to list the account names and not all the other details, simply run the commands below: That should list only the account names on the system beginning with the root account. That’s option number 1

Get User List via Getent Tool

Another option to get all user accounts on the system is to use the getting tool. This tool does a similar function as the commands above. It lists the content of the /etc/passwd file using the database info stored in the /etc/nsswitch.conf file. To get the lists of users using the getent, run the commands below: It should list the same content as above: The /etc/nsswitch.conf is used to configure which services are to be used to determine information such as hostnames, password files, and group files. These two options should be enough to get you a list of users on Linux systems, including Ubuntu.