Linux
chown & Ownership
Change owner/group; only root can give a file away.
Concept core idea Watch out easy to get wrong
Concept
Key concepts
chown user file,chown user:group file,chown :group file(group only);-R= recursive.chgrp group filechanges only the group.- Only root (sudo) can change a file's owner — a regular user can't give their file away or take another's. The owner CAN change the group to one they belong to.
- Ownership + rwx triplets together gate access: a process's UID/GID is checked against owner/group/other bits on every open/read/write.
id= your UID/GID/groups;whoami= your username.- Systems relevance: deploying a service = chown binary/data to a service user; setuid / privilege-dropping daemons rely on ownership.
Watch out
Easily confused
chown vs chgrp
chown changes owner (and optionally group); chgrp changes only the group.
id vs whoami
id shows your UID/GID and all groups; whoami shows just your username.Test yourself
6 questions on this lesson. Write your answers from memory, then compare them with the model answers side by side.