How to List Users in CentOS 7

IN Linux Centos7 Details of the users stores in /etc/passwd file. While there is no single command in Linux to List all users on the server, What we can do is to use cat or getent command to print the content of the passwd file.

cat /etc/passwd

This will list all the of the entries of the password file, Including usernames, user id, group id and home Directory.

cat /etc/passwd

To Get Only the Usernames from passwd file Type

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

Shell Scripting: How to Automate Command Line Tasks Using Bash Scripting and Shell Programming

getent command

Also, we can use getent command to get entries from the passwd file and display the user list in CentOS 7.

getent passwd

getent command

We can also pass the username with the getent command to Get Only the Information about specific user only.

getent passwd username

Even though I used CentOS 7 For This Article, What you learned here can be used in any Linux Distribution to list users.