chmod command
Modify file and folder permissions commands
short for change the permissions mod e of a file
Syntax: chmod [{ugoa}{+-=}{rwx}[file or directory]]
eg:chmod g=rwx,o=rwx test.txt to authorize read and write execution of the user group and other users of the test.txt file
chmod +x xxx Grant executable permission to all users to operate xxx file
chmod -x xxx Reclaim executable permission to all users to operate xxx file
chmod u+x xxx Increase executable permission to current user
chmod 755 xxx grants executable permission to xxx file in 9-bit notation (755=111101101)
9-bit representation of permissions:
rwxrwxrwx
9-bit indicates that the permissions corresponding to the three groups of read, write and execute permissions
are:
Group 1: Permissions owned by the owner of the
file Group 2: Permissions owned by users in the same group as the owner of the file
Group 3: Permissions the remaining users have
digital representation of permissions
r----4
w---2
x----1
So the digital representation of rwxrw-r-- is 764
chmod 764 test.txt
-R parameter recursively modify
chown command
Change the owner of a file or directory
English abbreviation of change file own ership
Only the owner and administrator of the file have permission to modify the group to which the file belongs.
Syntax: chown [user] [file or directory]
chgrp command
Modify the group to which a file or directory belongs
English abbreviation of change file gr ou p ownership
Syntax: chgrp [user group] [file or directory]
umask instruction
the u ser file-creation mask English abbreviation
Display and set default permissions for files
Syntax umask [-S]
Show default permissions for settings files
0022 explained
0 special permissions
022 --- -w- -w-
755 rwx rwx rwx
022 --- -w- -w-
-----------------
rwx rx rx directory
rw- r-- r-- file
umask 022 can modify the default permissions for creating files (but not recommended)