Next, let's talk about folder permissions in Linux.

Source: Internet
Author: User

Some netizens said that the log I wrote was too simple. Well, I will give it a little more details. In fact, it is very difficult: For details, don't want to see it. For simple reasons, you can't understand it!

InHomezzIn the data transfer process of several servers after. com, manyHomezzThe. com user is transferred to the newThe folder permission settings are incorrect. The old host is too open and does not have strict security performance control. Therefore, the File Permission is too large and there is no restriction on the security mechanism of the new server. Therefore, the server with too many permissions will reject the execution. The following describes the file permissions in Linux.

Linux's File Permission is one of the greatest guarantees for Linux's security performance. Some may know that, many methods of attacking windows are to obtain the permissions of creating users through vulnerabilities to control computers. in Linux, the root account has the maximum permissions and can do everything, other users can only have all the permissions of their own files and the permissions granted to the files by the members of the Change Group. The following describes the file permissions.

Read Permission R.Simply put, it is the permission to open the file to view the content. On the web server, if the file does not have the permission to open, the web server considers the file does not exist and sends the 404 file not found error,Use numbers4.

Write Permission W.OneFileIf you do not have the write permissionFileCannot be changed,FolderIf you do not have the write permissionFolderCannot create new files,Use numbers2.

Execution permission X.ProgramTo execute a file, you must have the execution permission; otherwise, the file cannot be executed. Opening a folder is also executed, soIf the folder does not have the execution permission.Use numbers1.

Who has this permission? File owner Group users Public users
Readable = 4 0 0 0
Writable = 2 0 0 0
Executable = 1 0 0 0
Actual permissions, vertical Addition 0 0 0

A public user is the owner and a user outside the group. For example, when accessing the Web, Linux may use a public user to read files. It may be understood as the user that a visitor can operate on.

The following example (again, the folder and file are different ):

All file users can write: 666 (three types of users can read and write)

Who has this permission? File owner Group users Public users
Readable = 4 4 4 4
Writable = 2 2 2 2
Executable = 1 0 0 0
Actual permissions, vertical Addition 6 6 6

Next, let's assume that the folder is set to 0666 and the result is obvious. Because the folder has no execution permission and cannot be opened, setting it to 0666 cannot be accessed.

The folder can only have all permissions of the file owner, including group users and public users reading and executing (755 ).Generally, you need to set the web root directory folder in this way.. Prompt again:The user cannot open the folder because the folder has no execution permission.. If the root directory permission is 0777 on a normal server, the error 500 is returned.

Who has this permission? File owner Group users Public users
Readable = 4 4 5 4
Writable = 2 2 0 0
Executable = 1 1 1 1
Actual permissions, vertical Addition 7 5 5

If php needs to create a file in a folder, set all permissions for the file:You can write or execute 777

Who has this permission? File owner Group users Public users
Readable = 4 4 4 4
Writable = 2 2 2 2
Executable = 1 1 1 1
Actual permissions, vertical Addition 7 7 7

For the sake of security, the normal PHP file should be set to: Owner readable and writable, group users readable and public users readable.644

Who has this permission? File owner Group users Public users
Readable = 4 4 4 4
Writable = 2 2 0 0
Executable = 1 0 0 0
Actual permissions, vertical Addition 6 4 4

For other permissions, please think about it yourself.

For those who suggest setting all files and folders to 777, I can only say that you are either misleading others or killing new users!

Related Article

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.