Coreutils chmod

From wikinotes

chmod changes permissions granted to a file's owner/group/other.

Basics

ex: 
  if file is owned by user will, and group wheel  (will:wheel)
  user will (who also belongs to group wheel) wants full access to the files
  user Alex (who only belongs to group wheel but isn't user will) only wants read access to the files

chmod can be used in 3 ways:

  • manually defining (u)ser, (g)roup, and (o)ther permissions, one at a time (ex chmod g+rwx)
  • changing permissions for all at once with number (ex: chmod 775 (u:rwx g:rwx a:rw)
  • manipulating the sticky bit, and changing file permissions (complicated)

(ugo)+rwx

chmod u+rwx  #change user permissions
chmod g+rwx  #change group permissions
chmod o+rwx  #change other permissions (all users/unidentified)

octal permission

## format:   chmod    owner-group-others

## Octal Num    in letters     Meaning
| 0 || --- || || All access Denied
| 1 || --x || || Execute Only
| 2 || -w- || || Write Only
| 3 || -wx || || Write + Execute
| 4 || r-- || || Read Only
| 5 || r-x || || Read + Execute
| 6 || rw- || || Read + Write
| 7 || rwx || || Read + Write + Execute

ex:
chmod 775 = (u)rwx (g)rwx (o)rx
chmod 600 = (u)rw  (g)--- (o)---

stickiby (suid, sgid)

chmod g+s /my/dir
chmod u+s /my/dir

ls -lt  /my/dir   # ls, showing suid/sgid