How Linux servers set read and write permissions for files and folders

Source: Internet
Author: User
Tags readable

Ways to modify a file's read-write properties

For example: Modify the index.htm file to a writable, readable executable:

chmod 777 index.htm

To modify all the file properties under the directory writable readable executable:

chmod 777 * *

You can use * as a wildcard character in this command.

For example: Modify the properties of all HTM files:

chmod 777 *.htm

Ways to modify folder properties

Modify the directory/images/small to a writable, readable executable:

chmod 777/images/small

To modify all folder properties under the directory:

chmod 777 *

Replace the folder name with a *.

To modify all of the files and folders within a folder and the subfolder properties to be writable and readable to perform:

chmod -R 777/upload

Summarize the permissions differences for files and directories under Linux:

File: Read file contents (r), write data to File (w), execute file As command (x).

Directory: Read the file name (R) contained in the directory, write the message to the directory (add and delete the index point link), search directory (can use the directory name as the pathname to access the files and subdirectories it contains)
Specifically, that is:

(1) a user with read-only permission cannot enter the directory with a CD, and must have execute permission to enter it. (2) users with Execute permission can access files in the directory only if they know the file name and have read rights. (3) You must have read and Execute permissions to list the directory in LS, or use the CD command to enter the directory. (4) with write permission to the directory, you can create, delete, or modify any file or subdirectory under the directory, even if the file or subdirectory belongs to another user.

View Directory Permissions

To view the file permissions statement, enter in the terminal:

Ls-l xxx.xxx (xxx.xxx is the file name)

Then there will be similar messages, mostly these:

A total of 10 digits, of which:

The first one--it represents the type.
The middle three rw-represents the owner (user)
Then those three rw-represent groups (group)
The last three r--represent others (other).
Here's another explanation of the 9 digits in the back:

R indicates that a file can be read (read)
W indicates that the file can be written (write)
x indicates that the file can be executed (if it is a program)
-Indicates that the appropriate permission has not been granted
Now it's time to talk about modifying file permissions.

In Terminal input:

chmod o w xxx.xxx

Give other people permission to write xxx.xxx this file

chmod GO-RW xxx.xxx

Represents the deletion of read and write permissions for groups and others in xxx.xxx

which

U represents the owner (user) G for the owner of the group that is located on (group) O on behalf of others, but not u and G (Other) A for all people, that is, including u,g and or that the file can be read (read) w indicates that the file can be written (write) x Indicates that the file can be executed (if it is a program)

Where: Rwx can also be replaced by numbers

R------------4------------2------------1-------------0

Let's go:

Represents the Add permission
-Indicates delete permission
= indicates a permission to make it unique
When we all understand the above, then we often have some of the following permissions are easy to understand:

-RW-------Only theowner has read and write permissions-rw-r--r--(644) Only the owner has read and write permissions, and the group and others have only Read permissions -rwx------(. 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 can read, write, The permissions that are executed, the group and other people only perform the permissions -rw-rw-rw-(666) Everyone has read and write permissions -rwxrwxrwx (777) Everyone has read and write and Execute permissions

How Linux servers set read and write permissions for files and folders

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.