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.
Frequently Asked Questions
How to view user log files in Ubuntu 22.04?
User log files in Ubuntu 22.04 are stored in the /etc/passwd directory, containing login information for each user.
What command can I use to list all users in Ubuntu 22.04?
To list all users in Ubuntu 22.04, you can use the command: $ cat /etc/passwd.
How can I identify user roles in Ubuntu 22.04?
User roles can be identified by checking the user groups in the /etc/group file using the command: $ less /etc/group.
How to list only user names in Ubuntu 22.04?
To list only user names in Ubuntu 22.04, you can use the command: $ cut -d : -f 1 /etc/passwd.
What details are included in the user log information in Ubuntu?
User log information in Ubuntu includes the user's username, password status, User ID, user groups, home directory, and shell.
How to check user login information in Ubuntu 22.04?
To check user login information in Ubuntu 22.04, you can use the command: $ w.
Where are user roles stored in Ubuntu 22.04?
User roles in Ubuntu 22.04 are stored in the /etc/group file, which contains information about user groups.
What is the significance of the 'x' character in the user log file in Ubuntu?
In the user log file in Ubuntu, the 'x' character represents the password status of the user, indicating that the password is stored in a separate shadow file.