#Day 4 A Practical Guide to User Management in Linux

Umesh SalunkheUmesh Salunkhe
3 min read

Before diving into practical exercises, it's essential to understand key concepts related to user management:

Step 1: Understanding User Management Concepts

  • Users and Groups: Users are individuals who interact with the system, while groups are collections of users with similar permissions.

  • UID and GID: Every user has a unique user ID (UID), and every group has a unique group ID (GID). These IDs are numerical identifiers used by the system to identify users and groups.

  • Home Directory: Each user has a home directory where they store personal files and configurations.

  • Shell: The shell is the command interpreter that users interact with when logged into the system. It determines the user's command-line interface.

  • Password Management: Users have passwords associated with their accounts for authentication purposes.

Step 2: Practice Creating Users

Create a New User: Use the useradd command to create a new user. For example:

Note - " -m instruct the system to create a default home directory for the user" However User could be created with that option but it will not create a default directory for the user.

Set Password for the User: Use the passwd command to set a password for the new user:

Verify User Creation: Use the id command to verify that the user was created successfully:

This command displays information about the user "rushikesh", including UID, GID, and group memberships.

Step 3: Practice Modifying Users

Modify User Attributes: Use the usermod command to modify user attributes such as the username, home directory, or shell. For example

Note - It only changes the name of the user, the UID, GID, and group remains the same.

Step 4: Add a Group.

To create a new group, you can use the groupadd command followed by the name of the group you want to create:

To check the create group, navigate to the below path.

cat /etc/group

Modifying Group -

(Changing Group Name)

"sudo groupmod -n <new_group_name> <old_group_name>"

(Changing Group ID)

"sudo groupmod -g New_gid Group_name"

(Deleting Group)

"sudo groupdel group_name"

Step 5: Practice Modifying Users.

Adding Users to a Group:

To add users to a group, you can use the usermod command with the -aG option followed by the name of the group:

Here we have added user Tappu to the group rushikesh and buysiness_analyst

to check, use below command.

Removing Users from a Group:

To remove users from a group, you can use the gpasswd command with the -d option followed by the username and group name:

Delete User Account:

Use the userdel command to delete a user account:

Conclusion

User management is a critical skill for Linux system administrators. By practicing the steps outlined in this guide, you'll gain hands-on experience creating, modifying, and deleting users, which will strengthen your understanding of user management concepts. Remember to always exercise caution when making changes to user accounts, especially on production systems, to avoid unintended consequences. Happy learning!


"Thank you for joining me on this journey into DevOps! Your curiosity is the driving force behind this exploration. If you found value in these insights, I'm thrilled! Keep the DevOps flame alive, and stay tuned for more exciting adventures in the world of technology. Happy Learning! 🚀✨"

"Closing the gap between us—let's connect and make our virtual bond stronger on social media!

Click on -Umesh Salunkhe

1
Subscribe to my newsletter

Read articles from Umesh Salunkhe directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Umesh Salunkhe
Umesh Salunkhe