The first step to managing permissions on Ubuntu is knowing what users exist on the system. The easiest way to do this is by reading the /etc/passwd file which lists accounts registered on the system. This file is packed with a lot of information though. It includes system-created accounts as well, along with their name, UID, GID, home directory, login shell, etc. In order to find the user you’re looking for, you may have to filter the output. List All Users with /etc/passwd If you don’t have a lot of users on your system, simply listing all users from the /etc/passwd file will be the most straightforward approach. cat /etc/passwd The output will contain the username, followed by several separated by the : delimiter. anup:x:1000:1000:anup,,,:/home/anup:/bin/bash In the above example, the output can be interpreted as follows: anup – Username x – Encrypted password stored in the /etc/shadow file 1000 – User ID (UID) 1000 – User’s Group ID (GID) anup – Short description of user /home/anup – The user’s home directory /bin/bash – The user’s default login shell All of this info is useful in various scenarios. For instance, we’ll use the UID to filter users later in this article. If you only need the username though, you can use the compgen tool. compgen -u If you want to list users by groups instead, you can use cat /etc/group You can also filter the results with grep. For instance, you could list users belonging to the sudo group. cat /etc/group | grep sudo List Users with getent The getent command is an alternative way to display entries from the passwd database. As before, you can list all the entries with getent passwd You can use grep to check if a certain user exists like so getent passwd | grep anup You can also query the group database to list all members of a certain group. For instance, you can list all members of the sudo group with getent group sudo List Users with UID If you want to list users along with their UID, you can use the cut command with the delimiter and fields options like so cut -d: -f1,3 /etc/passwd How is this useful? On systems with a lot of users, it can be difficult to identify users because of all the system-created accounts. As regular users have UIDs starting at 1000, you can use the UID to filter the results. List Human Users Only We’ll use the same command to list users with their UID, pipe and filter the output to only display entries with UID 1000 or above, then display the username field only as the final output. cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 You can also add an additional criteria for this. This time, we’ll list users with a /home directory and UID >= 1000 using awk. This’ll ensure the listed users are human. awk -F: '/\/home/ && ($3 >= 1000) {printf "%s:%s\n",$1,$3}' /etc/passwd