When we administer Linux systems it is necessary that we have knowledge of various options to access the list of users and groups in the system, this allows us to have precise control to know what type of permissions to assign, what users to create or delegate permissions and at the level of groups we can create and manage groups for specific tasks, TechnoWikis will explain how to see users and groups in Linux..
The ability to view Linux system users using commands provides comprehensive and detailed information on account activity and configuration on a Linux system. These commands that we are going to see today provide important information for system administrators, being able to get hold of information related to users and groups in Linux quickly. We are going to see Linux System Users using different interesting commands.
To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE
How to see system users in Linux
To have access to the users we will take the data from the /etc/passwd route, this is a file where the information that is necessary during the login in Linux is stored, in this file we will see the list of current system accounts and it gives us details to manage such as user ID, group ID, home directory, shell and more useful administration options.
Step 1
We open the terminal and we will execute the following command:
less /etc/passwd
Step 2
By pressing Enter we will see all the registered users in the /etc/passwd file:
Step 3
Each line is divided into fields and, in turn, we can see these fields delimited by the colon character (
, to exit the results press the q key.
It is possible to generate the results without having access to all the details of the /etc/passwd file, in this case we will use the cut command and the -d parameter to split the results into colon delimiters as follows:
cut -d : -f 1 /etc/passwd
Step 4
There we see only the users without the other details.
step 5
Now if we want to see the current groups registered in the system, we execute the following:
less /etc/group
step 6
By pressing Enter we will see all the groups together with their details. To exit the results, press the q key.
step 7
In /etc/group we find the group information or the user groups are defined there, we see how all the fields are separated by colons ( . As in the
previous command, it will only be possible to access the group details by executing:
cut -d : -f 1 /etc/group
step 8
If we need to see the connected users we execute the letter “w”, this will list additional details of each user:
step 9
In addition to this command, it is possible to use “who” to have summarized results of the users connected to the session:
We see how listing system users in Linux is a simple but effective management task..