Contents
There are several ways you can obtain the list of users in Linux.
- Show users in Linux using less /etc/passwd. This command allows sysops to list the the users that are locally stored in the system.
- View users using getent passwd.
- List Linux users with compgen.
How do I get a list of users in Linux?
Get a List of All Users using the /etc/passwd File
- Local user information is stored in the /etc/passwd file.
- If you want to display only the username you can use either awk or cut commands to print only the first field containing the username:
- To get a list of all Linux users type the following command:
Where are users listed in Linux?
Every user on a Linux system, whether created as an account for a real human being or associated with a particular service or system function, is stored in a file called “/etc/passwd”. The “/etc/passwd” file contains information about the users on the system.