Can use symbolic or absolute values to modify permissions
# Using symbolic valueschmod [classes][operator][modes] <file># Using octal/absolute valueschmod <permissions-in-octal> <file>
classes
u: User
g: Group
o: Others
a: All of the above (default if omitted)
operators
+: adds permission
-: removes permission
=: exact permission
modes
r: read
w: write
x: execute
X: special execute
s: setgid or sgid
Popular examples
# make file executable to all userschmod +x test.txt# make file executable for user onlychmod u+x script.sh# deny write permission to group/otherschmod go-w test.txt# make file readable/executable by everyone but writable by owner only# -rwxr-xr-xchmod 755 script.shchmod u=rwx,go=rx script.sh# make file readable by everyone but writable by owner# -rw-r--r--chmod 644 file.txt# only owner can read/write, zero access to everyone else# -rw-------chmod 600 ~/.ssh/id_rsa# everyone can read/write/execute# -rwxrwxrwxchmod 777 public_file.txt
Extended Attributes (MacOS)
@ is present at the end of file permission flags
> touch notes.txt# add red label via Finder app on this file# list permissions> ls -al notes.txt-rw-r--r--@ 1 KartikeyKumar staff 0 28 Jun 19:58 notes.txt# view extended attributes> xattr -l notes.txtcom.apple.FinderInfo:com.apple.metadata:_kMDItemUserTags: bplist00?URed6