chmod — CHange file access permission MODesSummary : chmod is used to change the permission/access mode of the file(s) or Dir(s). There are three kinds of permissions that a user can have for a file:
r) Permission to read the file. For Dir, this means permission to list the contents of the Dir.
w) Permission to write to (change) the file. For Dir, this means permission to create and remove files in the Dir.
x) Permission to execute the file (run it as a program). For Dir, this means permission to access files in the Dir. There are three categories of users who may have different permissions to perform any of the above operations on a file:
u) The file’s owner.
g) Group users who are in the file owner’s group.
o) Everyone else. The permissions are stored internally as integers.
Value — Notation — Meaning Basic:
1 — x — Execute
2 — w — Write
4 — r — Read Extended:
3 (2+1) wx Write and Execute
5 (4+1) rx Read and Execute
6 (4+2) rw Read and Write
7 (4+2+1) rwx Read, Write and Execute Examples :
$ chmod 777 myfile -- All permission to all. Here permissionsare given in numerical format. $ chmod 755 f1 f2 -- Setting all permissions to owner and, Readand Execute permissions to group and others. $ chmod u=rwx,g=rx,o=rx myprg -- Same as above. But permissionsare given in symbolic format. $ chmod u+x,g+r,o-rwx myprg -- Add Exec permission to owner, AddRead permission to group and Remove all permission for others. $ chmod u-x,go-rx myfile -- Remove Exec permission for owner.Remove Read and Exec permissions for group and others. $ chmod -R 755 mydir -- Set the mode to files and Dirs recursively. $ chmod --reference=f1 f2 -- Set f1's mode to f2. $ chmod -c 755 myfile -- Verbose but report only if change is made. $ chmod -v 754 myfile -- Verbose output for every file processed.
Note: `chmod’ never changes the permissions of symbolic links. Read : man chmod / info chmod