Batch set folder 755, webpage file 644 permissions

Source: Internet
Author: User
Although we are more free to set up a website on VPS, we need to do the security settings of the space ourselves. Once the website space or webpage is insecure, other websites may be affected by Elevation of Privilege. Of course, we do not know much about security. This is mainly because I encountered a problem this morning, because the transferred website files are all 777 permissions, and then moved to the host, resulting in a 403 error message. This requires us to set 755 for all folders, set 644 for all webpage files. Many people will find that if you manually set

Although we are more free to set up a website on VPS, we need to do the security settings of the space ourselves. Once the website space or webpage is insecure, other websites may be affected by Elevation of Privilege. Of course, we do not know much about security. This is mainly because I encountered a problem this morning, because the transferred website files are all 777 permissions, and then moved to the host, resulting in a 403 error message. This requires us to set 755 for all folders, set 644 for all webpage files.

Many people will find it very troublesome to manually set the folder because there are folders and files under each folder. Is there a command that can be set directly?

SSH command method 1

find . -exec sh -c "if [[ -d "{}" ]]; then chmod 755 "{}"; else chmod 644 "{}"; fi " \;

SSH command method 2

find ./ -type d -print|xargs chmod 755;find ./ -type f -print |xargs chmod 644

Any of the above methods can solve the problem of setting folder 755 and webpage file 644 permissions.

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.