In Linux, user and group management is essential for managing system security, access
permissions, and overall organization of resources. Here’s an overview of common commands
and tasks involved in managing users and groups.
1. Managing Users
• Creating a User
sudo adduser username
This command creates a new user along with a home directory and sets initial configurations.
• Deleting a User
sudo deluser username.
• Listing Users
Users are listed in the /etc/passwd file. You can view it with:
cat /etc/passwd
2. Managing Groups
• Creating a Group
sudo addgroup groupname
• Adding a User to a Group
sudo usermod -aG groupname username
The -aG option adds the user to the group without affecting their other group memberships.
• Deleting a Group
sudo delgroup groupname
• Listing Groups
Groups are listed in the /etc/group file:
cat /etc/group
3. Setting Passwords and Permissions
• Setting/Changing a User Password
sudo passwd username
• Viewing User and Group Information
o To view detailed information about a user:
id username
4. Switching Users
• Switch to Another User
su - username
To return to the original user, type exit.
5. Managing Permissions
• Changing Ownership with chown
Change file ownership to a specific user and group:
sudo chown user:group filename
With these commands, you can manage users, groups, and permissions effectively in a Linux
environment.