How To List Users in CentOS 7

Reading Time: 2 minutes

Adding a user in CentOS is a common task for most Linux admins. User’s have unique username’s and occassionally you may wonder if a username is in use or need other details about the user (like their group ID). We’ll show you how to see a list of users by logging into your Liquid Web CentOS 7 server. Once you’ve logged in via SSH, you’ll be able to run the commands below and get the information you need. Let’s get started!

To get a simple list of user names, enter the command below and press Enter.

getent passwd | cut -d: -f1

This command gives us a list of users assigned to this CentOS server. If you’d like a more detailed list of user you can use the command below. Using the command will provide you with the username, UID, GID, User Details, their home directory path, and the Default Shell for the user.

getent passwd

Example Output:

In our example you’ll see each field is separated by colons. Let’s breakdown the sections to provide more information on the user.

  • Username-the user example is root. Other users include bin, daemon, systemd-network, among many others. These are for when these entities need to access the system.
  • Password-indicated by the letter x, you can also find this encrypted password in the /etc/shadow file.
  • UID-this is the user’s ID, indicated by number starting at 1000. The root user is special as its UID is 0.
  • GID-like the user ID, the group ID shows us the the group that a user belongs to. The GID also starts at 1000 and for root user the group number is 0.
  • User Details – usually you’ll find the user’s first name. Sometimes this field can also be left blank.
  • Home Directory- this is the path that a user is in when logging into the server. You can alter this path by chrooting a user’s path.
  • Default Shell- A shell allows for an environment where users interact with the server and the type of shell assigned allows for different usage. The /bin/bash shell allows for text files to run commands.

Author Bio

About the Author: Echo Diaz

Throughout Echo's four year stint as a technical support specialist, her passion for breaking down complex concepts has to lead to a career in professional writing. As a top tier support specialist, she adds a distinctive element to her written work that speaks to customer feedback and concerns.

Echo occasionally pops her head out from behind her computer to watch her dog energetically run around the yard and unabashedly shovels money into buying tickets to see her favorite musical artists.

Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support