Users and Permissions
Understand users, groups, and the chmod / chown commands.
On this page4 sections
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 |
Changing ownership
Permissions are only half the story - each file also has an owner (a user) and a group. chown changes one or both:
chown alice script.sh # give ownership to alice
chown alice:devs script.sh # set owner AND group in one go
chown :devs script.sh # change only the group
A common real pattern: put teammates in a shared group, then chown :teamgroup a project's files and chmod g+rwx the directory so everyone in that group can collaborate without being the file's owner.
Why this matters
Servers get hacked because files are too permissive. When in doubt, least privilege - grant only what is needed.
Challenge
Make script.sh executable for the owner only (no permissions for group or others).
Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.
Quiz
Lock in the concepts. Score at least 80% to mark the lesson complete.
Done with this one?
Skipped the challenge? You can mark the lesson complete by hand.