Relationship between Linux permissions and commands

Source: Internet
Author: User

Relationship between Linux permissions and commands

Very important! Relationship between permissions and commands:

We know that Linux permissions are very important for user accounts, because they can restrict users from reading, creating, deleting, and modifying files or directories! This chapter introduces the management commands of many file systems, and the sixth chapter introduces the meaning of many file permissions. In this section, we will combine the two to explain what commands can be run under what permissions! Pai_^

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 you allow a user vbird to 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 permission for each file/directory should be: dir1: at least x permission is required;
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 4096 Sep 22/
Drwxr-xr-x 6 root 4096 Sep 29 02: 21/home
Drwx ------ 6 student 4096 Sep 29/home/student
Drwxr-xr-x 6 student 4096 Sep 29/home/student/www
-Rwxr -- r -- 6 student 369 Sep 29/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!

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.