Ext: The author is Baidu account
The chmod command in a Linux system is primarily used to modify the permissions of directories and files, which are only available to the root user by default. The command is used for COMMAND + modify content + to modify the file or directory, and it has some options most commonly used is-r, meaning recursive processing, once the operation of the directory and the directory of all files under the same permission change occurs. The chmod command supports two modifications in the modified mode, as shown below.
Letter Operator Modification Method
The so-called letter operator modification is actually the representation of the letter representing the owner, group, and other user, using the operator to represent the text of the increment or decrement permission. Permission notes are divided into three kinds of read (R), write (W), execute (x), the operand is divided into three classes of owner (U), the owning Group (g), the other User (O), if the need to increase the permissions can be used (+), the cancellation permission can be used (=). As long as the Operation object, permission operator, permission combination can communicate the corresponding modification requirements to the system. For example, the increase of execution rights on the owner can be expressed as u+x, and the Write permission to other users can be represented as o-w.
Example 1:
Add the permissions of the/tmp/history directory under the system to the write permission of the owning group. Method: After the prompt enter the command chmod g+w/tmp/history , after the completion of the view found that the permissions of the directory has changed from Drwxr-xr-x to Drwxrwxr-x.
Example 2:
Set the other user rights of the/tmp/every directory under the system to be readable, non-writable, and non-executable. Method: Enter the command chmod o=r/tmp/everyafter the prompt, and the permission to view the discovery directory after completion has changed from Drwxr-xr-x to DRWXR-XR--。
Example 3:
The permissions for the/tmp/mobile file under the system are set to owner-readable, writable, non-executable, group-readable, non-writable, non-executable. Method: Enter the command chmod u-x,g-w/tmp/mobileafter the prompt, and the permission to view the found file has changed after completion. Note here that multi-element modifications need to be connected using ",".
Digital Configuration Modification Method
In Linux, the Read permission is set to 4, the Write permission is set to 2, and the execution permission is set to 1. The permissions of any object can be represented by a number of three digits. For example, 765 means (4+2+1) (4+2) (4+1), that is, the owner is readable, writable, executable, belong to the group readable, writable, other user-readable, executable. When you make permission settings, you can use the chmod+ number combination + file directory to be modified to complete the changes.
Example 1:
The permissions of the/tmp/hub file under the system are set to owner-readable, writable, non-executable, the owning group is readable, writable, non-executable, and other users are readable, non-writable, and non-executable. Method: After the prompt enter the command chmod 664/tmp/hub, after the completion of the view found file permissions have changed.
Example 2:
The permissions of the/tmp/history directory under the system are set to the owner-readable, writable, executable, the group is readable, writable, unenforceable, and other users are readable, non-writable, non-executable, and all the file directories in the directory are in the same setting. Method: After the prompt input command chmod-r 764/tmp/history, to complete the separate view of the directory and the file discovery has changed
linux--Modify directory and file Permissions command chmod