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.
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.