title | description | created | updated |
---|---|---|---|
chmod Linux Command |
chmod stands for "change mode". It is used to change the permissions to files/ directories |
2019-08-24 |
2023-10-12 |
chmod stands for "change mode". It is used to change the permissions to files/ directories
chmod [options] <permissions> <file_name>
Option | Description |
---|---|
-R | change permissions for files and directories recursively |
-v | Verbose(this display all the files that the command is processing) |
-c | Change (this will display only the files it is changing the permission for) |
-f | silent mode (this will supress errors) |
-h | this change the permission of the symbolic link instead of the main file |
chmod 777 foo.txt
Following are the four possible digits and their respective permissions
Digit | Permission |
---|---|
4 | read |
2 | write |
1 | execute |
0 | no permission |
Users can also sumup these digits and can use like following
Derived Digits | Permission |
---|---|
7 | 4+2+1 = read + write + execute |
6 | 4+2 = read + write |
5 | 4+1 = read + execute |
3 | 2+1 = write + execute |
Owner of the file can set different permissions for user, group & others
chmod u=rwx,g=rx,o=r foo.sh # this is same as chmod 754 foo.sh
u = user
g = group
o = others
r = read
w = write
x = execute