Linux change file and directory permissions issues

Source: Internet
Author: User

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:

      1. Users with read-only permissions cannot enter the directory with a CD: You must also have Execute permission to access it;
      2. Users with execute permission can access files under the directory only if they know the file name and have read rights;
      3. You must have read and Execute permissions before you can list the directory in LS, or use the CD command to enter the directory;
      4. 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

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.