Lesson 9 / 29
chmod & chown
Change permissions and ownership.
chmod — symbolic mode
Add or remove permissions with +/- on u (user), g (group), o (other), a (all).
chmod u+x deploy.sh # owner can execute
chmod go-w notes.txt # group & other lose writechmod — numeric mode
r=4, w=2, x=1 — sum them per triplet. 755 = rwxr-xr-x, 644 = rw-r--r--.
chmod 755 deploy.sh # owner: rwx, group/other: r-x
chmod 644 notes.txt # owner: rw-, group/other: r--chown — change ownership
chown changes a file's owner and/or group; usually needs sudo.
sudo chown alice deploy.sh
sudo chown alice:devs deploy.shQuick check: What does `chmod 644 file` set?
- rwxrwxrwx
- rw-r--r--
- r--r--r--
Answer
rw-r--r-- — 6=rw-, 4=r--, 4=r-- for owner, group, other respectively.