chmod Linux Command Cheatsheet




chmod stands for "change mode". It is used to change the permissions to files/ directories

Syntax

chmod [options] <permissions> <file_name> 

Example

chmod 777 foo.txt

Permissions

Following are the four possible digits and their respective permissions

DigitPermission
4read
2write
1execute
0no permission

Users can also sumup these digits and can use like following

Derived DigitsPermission
74+2+1 = read + write + execute
64+2 = read + write
54+1 = read + execute
32+1 = write + execute

Permissions for user, group, others

Owner of the file can set different permissions for user, group & others

Example

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


┬ęCopyright 2020 OneCompiler | Privacy Policy | Terms & Conditions