In Linux, managing user permissions typically involves three main levels: Ownership, Permissions (rwx), and Groups.
Since you just learned about adding a user to the sudo group, you've already started exploring the "Group" part of this system! Here is the breakdown of how it all works:
1. The Three Layers of Ownership
Every file and directory in Linux has:
- User (u): The specific user who owns the file.
- Group (g): A group of users who have shared access.
- Others (o): Everyone else on the system.
2. The Three Types of Permissions
- Read (r): Ability to view file contents or list directory files.
- Write (w): Ability to modify/delete files or create files in a directory.
- Execute (x): Ability to run a file as a program or "enter" (cd into) a directory.
3. How to Manage Them (The Tools)
A. Changing Permissions (chmod)
You use chmod (change mode) to add or remove permissions.
- Symbolic way:
chmod u+x file(adds execute to the user). - Numeric way:
chmod 755 file(User=Full, Group=Read/Exec, Others=Read/Exec).
B. Changing Ownership (chown)
If you want to change who owns a file (like giving a file to joker):
sudo chown joker:joker filename
(This changes both the owner and the group to joker).
C. Group Management (usermod & groups)
This is what you just did in the lab! By moving a user into a group, they inherit the permissions of that group.
- Add to group:
sudo usermod -aG groupname username - Check groups:
groups username
4. Special Permissions (Sudo)
As you saw in the last step, the sudo group is a "super" permission. It doesn't just give access to one file; it allows a user to bypass standard permissions by acting as the root user.
Summary Table:
| Command | Purpose |
|---|---|
ls -l |
View current permissions and owners |
chmod |
Change the read/write/execute settings |
chown |
Change the owner or group of a file |
usermod |
Add a user to a group (like you did with sudo) |
Would you like to try a small exercise to see these file permissions in action, or are you ready to continue with the user management lab?