Users and Permissions
Understand users, groups, and the chmod / chown commands.
Linux is a multi-user system. Every file belongs to a user and a group, and has three permission sets: owner, group, and everyone else.
Reading permissions
Run ls -l and you will see something like:
-rwxr-x--- 1 alice devs 1024 Jun 28 script.sh
Breakdown:
-- regular file (dfor directory)rwx- owner can read, write, executer-x- group can read and execute---- others have no access
Changing permissions
chmod 755 script.sh # owner: rwx, group+other: rx
chmod +x script.sh # add execute for everyone
chmod 600 secret.txt # owner only
The numbers are octal:
| Digit | r | w | x |
|---|---|---|---|
| 7 | yes | yes | yes |
| 6 | yes | yes | |
| 5 | yes | yes | |
| 4 | yes |
Why this matters
Servers get hacked because files are too permissive. When in doubt, least privilege - grant only what is needed.
Your notes
Notes are kept on this browser only.
Make `script.sh` executable for the owner only (no permissions for group or others).
Tip: type the command in the sandbox on the right, or paste the solution here. The sandbox runs in real time.
Answer these to lock in the concepts. Score at least 80% to mark the lesson complete.
Mark as complete
Skipped the challenge? You can mark this lesson done by hand.