User Management in Linux

Linux system administrators have a lot of problems to deal with, and managing user accounts is one of them. Assigning users to groups and shells, creating and removing user accounts, defining permissions, and maintaining passwords are all tasks that fall within the purview of a system administrator.

Only after learning the fundamentals of Linux account administration will you have complete command over your users’ access privileges. In light of that, consider this post a first step toward better protecting user accounts. Create, remove, and edit user accounts, as well as take control of any default Linux configurations or files, are all covered in detail to show you how to set up Linux in the safest and most appropriate manner possible.

Create a User

In Linux, each user has their own personal account that stores all of their data. The Linux user commands allow for the creation of numerous users inside the Linux OS. Creating a new user in Linux administration is the next step in this tutorial. A user is created by following these steps:

  • Use sudo command to create a new user
  • Set password for the new user
  • Enter details for the new user and confirm by hitting “Enter” after typing “y”
$ sudo adduser User_name
sudo adduser elearnbee_new_user

List Users

  • Use the following command to list users:
awk -F':' '{ print $1}' /etc/passwd

Delete a User

  • Use the following command to delete a user:
$ sudo userdel User_name
sudo userdel elearnbee_new_user

Add a User to a Group

Memberships in groups are checked to see if multiple users in a group have the rights and privileges they need. By using groups, we are able to eliminate the need of individually assigning permissions to users in order to guarantee that users inside a group have the necessary permissions.

  • Use the following command to add a user to an existing group:
$ sudo usermod -aG Group_name User_name 
sudo usermod -aG ELearnBee elearnbee_test
  • Use the following command to see users in a group:
$ awk -F’:’ ‘/Group_name/{print $4}’ /etc/group
awk -F':' '/ELearnBee/{print $4}' /etc/group

Delete a user from a group

  • Use the following command to delete a user from a group:
$ sudo gpasswd -d User_name Group_name
sudo gpasswd -d elearnbee_test ELearnBee

Feedback

Do you want to provide us with feedback? Provide us with feedback directly at info@elearnbee.com.

Share us:

AD BLOCK 1