chmod
chmod
(change mode) is the command to change permissions to system objects (files and directories).
$ chmod u+x filename
Useful Options / Examples
chmod
$ chmod [references][operator][modes] file ...
References include:
u
for userg
for groupo
for other
Operators include:
+
adds specified modes to specified classes-
removes specified nodes to specified classes=
will set specified classes to exact specified modes
Modes include:
r
(read)w
(write)x
(execute)
chmod [reference(s)][operator][mode(s)] file
$ chmod u+x file
$ chmod g-w, uo=rw file
Break it down
- The first command will add write permission for file to user
- The second command will remove write permission for group, and set user and other to have read and write permissions only
chmod --reference=[file1] [file2]
$ chmod --reference=file1 file2
Break it down
- Sets file2’s permissions to be the same as file1
chmod -R [reference(s)][operator][mode(s)] directory
$ chmod -R u+x directory-name/
Break it down
- Adds execute permission to users for all files under directory
chmod [reference(s)][operator][mode(s)] *
$ chmod u+x *
Break it down
- Adds execute permision to users for all subdirectories under directory