Basic Format
chmod [options] mode filePermission Types
r | Read permission |
|
w | Write permission |
|
x | Execute permission |
Permission Groups
u | User (owner) |
|
g | Group |
|
o | Others |
|
a | All (user, group, others) |
Examples
chmod 755 myfile.txt | Set rwx for user, and r-x for group and others. |
|
chmod u+x,g+w myfile.txt | Add execute permission for user, write permission for group. |
|
chmod a-w myfile.txt | Remove write permission from all groups (user, group, others). |
|
chmod -R 755 mydirectory | Recursively set permissions for directory and its contents. |
Options
-R
Change permissions recursively for directories.
--reference=RFLILE
Add execute permission for user, write permission for group.
Permission Modes
Numeric Mode: 4 : Read (r) 2 : Write (w) 1 : Execute (x) e.g., 755 - User: rwx (7) - Group: r-x (5) - Others: r-x (5) Symbolic Mode: + : Add permission - : Remove permission = : Set exact permission e.g., u+x - Adds execute permission for the user (owner).