Introduction to CentOS List Users
The CentOS environment, it is having the capability to manage multiple groups and multiple users also. Every user is having their own shell environment. Normally, we are working with the useradd or the usermod command. But if we need to list out the number of user in the CentOS environment, we can also do that. We are having different ways to do that. As per the requirement, we need to choose the way or method to list out the number of users form the CentOS ecosystem. In terms of the security application or tool, we can also use the user list information in it.
Syntax of CentOS List Users:
As such, there is no exact syntax available to list out the users from the CentOS environment. Usually, we are using a number of tools or methods. As per the condition or application use case, we can use the essential method or the tool to get the list of users from the ecosystem.
Sample method to get the user list:
cat /etc/passwd | grep -i ( USER NAME )
- cat /etc/passwd: The cat is nothing but a command to read the file. It is reading the file content of the “passwd” file. In the same file, we are getting all the user-level information, i.e., those users are available in the environment.
- grep: It is a utility to capture the specific information from the file.
- Options: We can provide the different flags as the option that is compatible with the command.
- USER NAME: As per the requirement, we can use the user name in the command.
How CentOS List Users Works?
Once we will list out the users from the “/etc/passwd” file, we will get the information line by line.
Below are the lists of the tab that are in the “/etc/passwd” file.
In the CentOS operating systems, we are using the alphanumeric format to create the Username. We can also create a numeric user ID also. It is called the user ID or the UID in the CentOS ecosystem. For ordinary or the normal user, the UID starts from the integer value of one thousand, i.e., 1000. But the root user has the unique id, i.e., the UID 0.
In the CentOS ecosystem, we can use the group name with a name and a numeric combination. The same ID is called the Group ID or the GID. On Linux distribution, every user is a part of at least one group. Hence, when we will create any user in the Linux environment, it should only be part of the same group. While doing this process. The GID of the primary group is added.
We can say that the primary group is the main or default group of the user. Then further, we can add the user in the different groups also. The normal or the ordinary groups start at the value 1000. In some cases, the Linux environment is not properly configured, then the UID and the GID both are the same. But the root group has the unique id, i.e., the GID 0.
3. User Details
In this field, we can add the full name of the user for better clarification. We can also add the other personal information they uses. We can use the comma-separated list also. But normally, the common use of this field is to set the user’s complete name in it. Setting the full name is very easy; we need to type the user’s full name. Once it adds over here, it will automatically set.
4. Home Directory Path
This field will help to set the directory path of the user. It will help to set all the necessary user files in the same directory location. We can also use the $HOME variable is set from this field in the CentOS environment.
5. Default Shell
On Linux distribution, we need to set the shell for the individual user. By default, we can set the shell environment, i.e., the sh (/bin/sh) environment. We can also set the different environments also, i.e., the bash (/bin/bash) shell environment. Generally, we can set the shell or bash for ordinary or the normal users who want to log in to the CentOS ecosystem.
Similar to shell or bash, we are having different shells as well, like csh, zsh, etc. In the CentOS system, the system users are having the /sbin/nologin shell. Hence they are not able to login into the shell environment. If we need to log in, the system is used to log in to the shell environment. It is possible to do that; we just need to change the login shell option.
Examples of CentOS List Users
Given below are the examples of CentOS List Users:
CentOS List Users: Get the list of user.
In the CentOS environment, we are able to list out the number of users.
We are using a different command like the “cat” command and access the “passwd” file to get the information.
- As per the above command, we are able to get the list of users in the CentOS environment. We are using the cat command to read the “passwd” file.
CentOS List Users: Get the specific user.
In the CentOS environment, we are having the functionality to fetch specific user information.
cat /etc/passwd | grep -i user3
- As per the above command, we are fetching the “user3” user information. Here, we are using the cat command with the pipe and grep command.
We have seen the “CentOS List Users” uncut concept with the proper example, explanation, and command with different outputs. By default, there is no specific syntax to get the list of the user. We need to use different tools or methods to extract information. As per the requirement, we need to use it and get the necessary details.
This is a guide to CentOS List Users. Here we discuss the introduction, how CentOS list users works? and examples, respectively. You may also have a look at the following articles to learn more –