We know that permissions are very important for user accounts, because they can restrict users from reading, creating, deleting, and modifying files or directories.
1. What are the basic permissions for allowing users to access a directory to become a "working directory:
- Commands that can be used: commands such as CD to change the working directory;
- Permission required for a directory: the user must have at least X permissions for this directory.
- Additional requirement: if the user wants to use ls to check the file name in this directory, the user also needs the r permission for this directory.
2. What is the basic permission of a user to read a file in a directory?
- Available commands: for example, Cat, more, less, etc. mentioned in this Chapter
- Permissions required for a directory: the user must have at least X permissions for the directory;
- Permissions required for files: users must have at least R permissions on files!
3. Why can users modify the basic permissions of a file?
- Available commands: Nano or the VI editor to be introduced in the future;
- Directory Permissions: the user must have at least X permissions in the directory where the file is located;
- File permissions: users must have at least R and W permissions on the file.
4. What is the basic permission for a user to create a file?
- Permissions required for a directory: the user must have permissions W and X in this directory, focusing on W!
5. What are the basic permissions for a user to access a directory and run a command under the directory?
- Directory Permissions: the user must have at least X permissions in the directory;
- File permissions: users must have at least X permissions on the file.
Example: when a user vbird can run the "CP/dir1/file1/dir2" command, what are the minimum permissions required for dir1, file1, and dir2? A: When running CP, vbird must "be able to read the source file and write it to the target file !』 Therefore, please refer to the instructions on the second and fourth points above! Therefore, the minimum permissions for each file/directory should be:
- Dir1: requires at least X permissions;
- File1: at least the r permission is required;
- Dir2: requires at least W and X permissions.
|
Example:
The full name of a file is/home/student/www/index.html. the permissions for related files/directories are as follows:
drwxr-xr-x 23 root root 4096 Sep 22 12:09 /drwxr-xr-x 6 root root 4096 Sep 29 02:21 /homedrwx------ 6 student student 4096 Sep 29 02:23 /home/studentdrwxr-xr-x 6 student student 4096 Sep 29 02:24 /home/student/www-rwxr--r-- 6 student student 369 Sep 29 02:27 /home/student/www/index.html
Can the vbird account (not in the student group) read the index.html file?
A:
Although WWW and index.html allow vbird to read, the directory structure is read by the root directory layer, therefore, vbird can enter/home, but cannot enter/home/student/. Since it cannot even access/home/student, of course it cannot read index.html! So the answer is "vbird won't read index.html content!
How can I modify permissions? In fact, you only need to change the/home/student permission to a minimum of 711, or directly give 755! This is an important concept!