Lesson 2: Understanding File Permissions
In Linux, everything is a file, and every file has Permissions. This is the heart of Linux security.
The Three Musketeers: Owner, Group, Others
Every file has three types of people who can interact with it:
- Owner (u): Usually the person who created the file.
- Group (g): A collection of users with shared access.
- Others (o): Everyone else on the system.
The Three Powers: Read, Write, Execute
For each type of person, we can grant or deny:
- Read (r): Ability to see the contents.
- Write (w): Ability to change the contents.
- Execute (x): Ability to run the file (if it's a script or program).
Interactive Mission
Let's look at a real-world example. On a server, the /etc/shadow file contains encrypted passwords. Only the root (admin) user should be able to read it.
booting...
Steps to Complete:
- Who are you? Type
whoamito confirm you are the root user. - Inspect the target: Use
ls -l /etc/shadowto see its permissions. You'll see something like-rw-r-----. - Create your own secure vault: Create a file named
secure.txtand make it so only you can read or write to it usingchmod 600 secure.txt.