User and Group Management Explained
Key Concepts
- User Accounts
- Group Management
- File Permissions
- User Management Commands
User Accounts
User accounts are essential for managing access and permissions on a Linux system. Each user has a unique username and user ID (UID). User accounts can be created, modified, and deleted using specific commands.
Imagine user accounts as individual keys to a house. Each key (user) has a unique identity and can unlock specific doors (resources) based on their permissions.
Example: To create a new user named "john", you would use the command sudo useradd -m john
. This command creates a home directory for "john" and sets up the necessary files.
Group Management
Groups are collections of users that share common permissions. Group management allows administrators to assign permissions to multiple users simultaneously. Each group has a unique group name and group ID (GID).
Think of groups as families sharing a single key to a house. Each family member (user) can access the house (resources) based on the permissions granted to the family (group).
Example: To create a new group named "developers" and add the user "john" to it, you would use the command sudo groupadd developers
followed by sudo usermod -aG developers john
.
File Permissions
File permissions determine who can read, write, or execute files and directories. Permissions are assigned to three categories: owner, group, and others. The chmod
command is used to change file permissions.
Consider file permissions as locks on a safe. The owner (user) has the master key, the group members have a shared key, and others have no key. The chmod
command allows you to change the locks.
Example: To give the owner and group members read and write permissions to a file named "report.txt", you would use the command chmod 660 report.txt
.
User Management Commands
User management commands are essential for creating, modifying, and deleting user accounts. Key commands include useradd
, usermod
, and userdel
.
Think of user management commands as tools for managing keys to a house. The useradd
command creates a new key, usermod
modifies an existing key, and userdel
removes a key.
Example: To delete a user named "john" and remove their home directory, you would use the command sudo userdel -r john
.