Users and Groups

Module 3: Users and Groups

Lesson 1: User Management

1.1 Creating and Deleting Users

1.1.1 Creating Users

To create a new user in Linux, we use the useradd command. For example:

sudo useradd -m username

This creates a new user with a home directory (-m option).


1.1.2 Deleting Users

To delete a user, we use the userdel command. This command removes the user and optionally deletes the home directory:

 

sudo userdel -r username

1.1.3 Managing User Properties

Changing Password:

sudo passwd username


Changing User Information:

sudo usermod -c "New User Name" username

Lesson 2: Group Management

2.1 Creating and Deleting Groups

Creating a Group:

sudo groupadd groupname

Deleting a Group: 

sudo groupdel groupname

2.2 Managing Group Memberships

Adding a User to a Group:

sudo usermod -aG groupname username

Removing a User from a Group:

sudo deluser username groupname


In this module, we've explored user and group management in Linux. We learned how to create and delete users using the useradd and userdel commands, and how to modify user properties. Additionally, we covered group management, including the creation and deletion of groups, as well as managing group memberships. These skills are crucial for effective system administration, allowing us to control access, permissions, and organizational structure within the Linux environment. As we progress in our Linux journey, mastering user and group management becomes essential for maintaining a secure and organized system.