chmod [options] mode files
Only the file owner or privileged user can use this function to change the file access mode. mode can be in numerical form or expressed in the form of who opcode permission. Who is optional, default is A (all users). Only one opcode can be selected. Multiple modes can be specified, separated by commas.
options:
-c,--changes Only the information of the changed file is output
-f,--silent,--quiet When chmod cannot change the file mode, the user of the file is not notified
--help Output help information.
-R,--recursive You can recursively traverse the subdirectory and apply the modification to all files and subdirectories in the directory
--reference=filename Refer to the filename permission to set the permissions
-v,--verbose Regardless of whether the modification is successful or not, output information for each file
--version Output version information.
who
u user
g group
o Others
a All Users (Default)
opcode
+ Increase permissions
- Remove permissions
= Reassign permissions
permission
r Read
w write
x execute
s Set the ID number of the user (or group).
t Set a sticky bit to prevent files or directories from being deleted by non-owners
u The user's current permissions
g The group's current permissions
o Current permissions for other users
As a choice, most of us use the form of three-digit octal numbers to represent permissions, the first to specify the permissions of the master, the second to specify the permissions of the group, and the third to specify the permissions of other users, each by the sum of three values: 4 (read), 2 (write), and 1 (execute) to determine the permissions. For example, 6 (4+2) represents the right to read and write, and 7 (4+2+1) has the right to read, write and execute.
You can also set the fourth digit, which is located in front of the three-digit permission sequence, and the fourth digit is 4, 2, 1, which means the following:
4. Set the user ID during execution, which is used to authorize the process based on the file owner, not to the user who created the process.
2. Set the user group ID during execution, which is used to authorize the process based on the group where the file is located, not based on the user who created the process.
1. Set the adhesive position.
Instance:
$ chmod u+x file adds execution permissions to the owner of the file $ chmod 751 file assigns read, write, and execute permissions to the file's owner (7), reads and executes (5) to the file's group, and assigns execution (1) permissions to other users $ chmod u=rwx,g=rx,o=x file Another form of the example above $chmod=r file assigns read permissions to all users $ chmod 444 file Same as above $ chmod a-wx, a+r file as above $ chmod -R u+r directory recursively assigns read permissions to the owner of all files and subdirectories in the directory $ chmod 4755 sets the ID to assign read, write and execute permissions to the subordinate, and assign read and execute permissions to the group and other users. |