The process of managing and allocating different privileges to the users in a multi-user environment is the fundamental responsibility of a system admin. The responsibilities of a system admin include monitoring the users’ login information and the activities performed by them. Ubuntu 22.04 provides some features to maintain users’ logs in the systems.
In this article, we will elaborate on the users and roles of users in Ubuntu 22.04.
How do I see users and roles in Ubuntu?
Every operating system maintains a log file for every user that login to the system. In Ubuntu 22.04, a user log file is stored in /etc/passwd directory. This file maintains the user’s login information. For determining these users and roles let us discuss some commands that will help us to understand, listing down the users and their roles in Ubuntu 22.04.
List Down All the Users
We can list down the users by using the following command:
$ cat /etc/passwd
The command displays the following output:
Understanding the Output
In the above figure:
- The first character displays the username
- The next character “x” represents the password
- User Id and user groups are displayed in the next two characters
- Optional details of the user
- Directory used by the user
- Shell used by the user
You can list down only users with the following command:
$ cut -d : -f 1 /etc/passwd
The command displays the individual users on a single line:
Listing Down the User Groups
To discover the user groups use the file /etc/groups, and execute the following command to view the user groups:
$ less /etc/group
The command is shown as:
The output is as follows:
Listing Down the Users Login Information
Use the following command to list down the login information:
$ w
The command displays the user type and login information:
An alternative way is to use the command “who”:
$ who
The command displays the output as follows:
Check User Roles
If you want to check the user role of a specific user, run the following command:
$ sudo -l -U "<username>"
The command will display the user’s role as follows:
The output shows that this specific user has the root privileges. The last line describes that ubuntu8(username) can run all the commands with sudo permissions. This is how you can see users, user logs, and user roles in Ubuntu 22.04.
Conclusion
To see the users’ details, and roles of the users in Ubuntu 22.04, you can use the terminal and see the information of different users. The /etc/passwd directory provides the details for every user log information. This article has provided a detailed overview of users and the roles of users using the terminal.