1. Fast Example Learning
Modify the permissions for all files under a directory, including files in subdirectories, as shown in the following example:
chmod 777 /home/user Note: only/home/chmod777 /home/user Note: Indicates that the entire/home/ The user directory and the permissions for the files and subdirectories in it are set to rwxrwxrwx
where the parameter-R indicates the start-up recursion process
2. chmod command parsing:
CHMOD uses 3 numbers to express the permissions of the user (the owner of the file or directory), the user group (the same group of users), and other users:
such as: chmod 777/test
The number 7 is the expression that has both read, write, and Execute permissions: Read--denoted by the number 4;
Write--represented by the number 2;
Implementation-represented by the number 1;
Follow the rules, such as the permissions you want to set the/test directory to:
To user-readable writable: 4 (Read) + 2 (write) = 6;
Readable executable for user group: 4 (Read) + 1 (execution) = 5;
Readable to other users only: 4 (read);
This allows you to use the command:
chmod 654/test
3. Permission resolution:
Three types of permissions for files:
Read file contents (r), write data to File (w), execute file As command (x)
Three types of permissions for the directory:
Read the name of the file contained in the directory (r);
Write the message to the directory (add and remove links to index points, W);
The search directory (which can use the directory name as the pathname to access the files and subdirectories it contains);
Specific Description:
-
- Users with read-only permissions cannot enter the directory with a CD: You must also have Execute permission to access it;
- Users with execute permission can access files under the directory only if they know the file name and have read rights;
- You must have read and Execute permissions before you can list the directory in LS, or use the CD command to enter the directory;
- There is a write permission to the directory to create, delete, or modify any file or subdirectory under the directory, even if the file or subdirectory belongs to another user;
Several common permission instances:
-RW-------(600) Only the owner has read and write permissions
-rw-r--r--(644) Only the owner has read and write permissions, and the group and other people only have Read permissions
-RWX------(700) Only the owner has read, write, execute permissions
-rwxr-xr-x (755) Only the owner has read, write, execute permissions, groups and other people only read and Execute permissions
-rwx--x--x (711) Only the owner has read, write, execute permissions, groups and other people only execute the permissions
-rw-rw-rw-(666) Everyone has access to read and write
-RWXRWXRWX (777) Everyone has access to read and write and execute
Linux change file and directory permissions issues