The relationship between Linux permissions and commands

Source: Internet
Author: User
Tags file permissions

extremely Important! The relationship between permissions and commands:

We know that permissions are very important to the user account because he can restrict users from reading/creating/deleting/modifying files or directories! In this chapter we introduce a lot of file System management commands, the sixth chapter introduces the meaning of many file permissions. In this section, we will combine the two to explain what kind of command under what permissions to run it! ^_^

First, allow users to enter a directory to become a "working directory" of the basic permissions:

    • Commands that can be used: such as CDs and other commands to transform working directories;
    • Permissions required by the directory: The user must have at least X permission on this directory
    • Additional requirements: If the user wants to use the LS lookup file name in this directory, then the user also needs R permission on this directory.

Second, the user in a directory to read a file's basic permissions?

    • Commands you can use: for example, cat, more, less, and so on in this chapter
    • Permissions required by the directory: the user must have at least X permission on this directory;
    • Permissions required for the file: The user must have at least R permission on the file!

Third, let the user can modify the basic permissions of a file?

    • Available commands: such as the Nano or the VI Editor to be introduced in the future;
    • Permissions required for the directory: the user must have at least X permission in the directory where the file resides;
    • Permissions required for the file: The user must have at least R, W permissions on the file

Iv. What are the basic permissions for a user to create a file?

    • Permissions required for the directory: The user must have W,x permissions in the directory, focusing on W!

What are the basic permissions for users to enter a directory and run a command in that directory?

    • Permissions required by the directory: the user must have at least X permission on the directory;
    • Permissions required by the file: the user must have at least X permission on the file
Example: Let a user vbird be able to "CP/DIR1/FILE1/DIR2" command, please explain Dir1, file1, dir2 the minimum required permissions? A: When running CP, Vbird to "be able to read the source file and write to the target file!" "So refer to the 2nd and 4th instructions above!" Therefore, the minimum permissions for each file/directory should be:
  • Dir1: At least x permission is required;
  • File1: At least R permission is required;
  • Dir2: At least W, x permission is required.

Example: There is a full file name of/home/student/www/index.html, the permissions of each related file/directory are as follows:
Drwxr-xr-x root    root    4096 Sep 12:09/drwxr-xr-x  6 root    root    4096 Sep 02:21/homedrwx------
      6 Student Student 4096 Sep 02:23/home/studentdrwxr-xr-x  6 student student 4096 Sep 02:24/home/student/www-r wxr--r--  6 student student  369 Sep 02:27/home/student/www/index.html
May I ask Vbird this account (not belong to student group) can read index.html this file? A: Although www and index.html are allowed to Vbird Read permissions, but because the directory structure is a layer of root directory read, so vbird can enter/home but not into/home/student/, since even enter/home/studen T is not allowed, of course, can not read the index.html! So the answer is "Vbird won't read the content of index.html" Oh!

So how do you modify permissions? In fact, as long as the/home/student permission to modify the minimum 711, or give 755 directly can Luo! That's a very important concept.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Relationship between Linux permissions and commands

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.