Chmod-change the access mode of one or more files. chmod [Options] mode files can only be used by file owners or privileged users to change the file access mode. Mode can be in the digital format or in the WHO opcode permission format. Which is optional. The default value is a (all users ). Only one opcode can be selected ). You can specify multiple modes separated by commas. Options:-C, -- changes only outputs the information of the changed file-F, -- silent, -- quiet. When chmod cannot change the file mode, the user -- Help of the file is not notified to output help information. -R, -- Recursive recursively traverses sub-directories, and applies the modification to all files and sub-directories in the directory. -- reference = filename sets the permission by referring to the filename permission.-V, -- verbose outputs the version information of each file no matter whether the modification is successful or not. Whou user G group O all other a users (default) opcode + add permissions-delete permissions = re-assign permissions permissionr read w write x execute s set users (or groups) ID of t to Set Sticky
To prevent files or directories from being deleted by a non-owner, most of us use three Octal numbers to indicate permissions. The first one specifies the permissions of the owner, the second one specifies the group permissions, and the third one specifies the permissions of other users. Each user passes 4 (read) the sum of 2 (write) and 1 (execution) Values to determine permissions. For example, 6 (4 + 2) indicates that you have the read and write permissions, and 7 (4 + 2 + 1) indicates that you have the read, write, and execution permissions. You can also set the fourth digit, which is located before the three-digit permission sequence. The fourth digit is 4, 2, and 1, which indicates the following: 4. Set the user ID during execution, used to authorize a process based on the file owner, rather than to the user who creates the process. 2. Set the user group ID during execution to authorize the process based on the file group, instead of the user who creates the process. 1. Set the adhesion position. Instance: $
Chmod U + X file adds the execution permission to the file owner $ chmod 751 the file owner is assigned the read, write, and execute (7) permission, assign the read and execute (5) permissions to the group where the file is located, and assign the execution (1) permissions to other users $ chmod u = rwx, G = RX, O = another form of example on X file $ chmod = r file assigns read permissions to all users $ chmod 444 file same as above $ chmod A-WX, A + R file: Same as above $ chmod-r u + r directory
Recursively assign 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 owner, assign read and execution permissions to the group and other users.