Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

file - What is the normal chmod?

On my web server, my file permissions are all over the place and I want to 'reset' everything back to how it originally was. I don't want any users to be able to come in and delete things off my web server! I just want them to be able to look at php pages etc.

What chmod should I use?

question from:https://stackoverflow.com/questions/695497/what-is-the-normal-chmod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's a summary that I have gathered

  • chmod all files to 644
  • chmod all .htaccess files to 644
  • chmod all robots.txt files to 644
  • chmod all directories to 711
  • chmod all directories with directory listing (.htaccess Options +Indexes) to 755
  • chmod all directories that users can upload files to, to 755 (ex: /uploads/).

Explanations:

  • 644 means:
    • 6: the owner of the file/directory can read and write, but not execute. Since files are not executable, you don't need to have "x" rights here (6 means r+w. 7 means r+w+x).
    • 44: The group that the file/directory belongs to (see the group by using ls -l) and everyone else (the public) are able to read the file, but not execute or write to it (permission number 4).
  • 711 means:
    • 7: the owner of the file/directory can read, write, and execute. This is needed for directories! Without "execute" when you try to list the directory you'll get permission denied.
    • 11: The group that the file/directory belongs to and the public have execute rights only. This is suitable for directories where you don't want other people browsing through the contents but do want to give them access to selected files further down the directory.
  • 755 means:
    • 7: the owner of the file/directory can read, write, and execute.
    • 55: The group that the file/directory belongs to and the public have read and execute permissions but not write. This allows users to be able to view what files are in a directory, and be able to read those files, but not alter them.

There's also an interactive online calculator you can use to figure out what permissions to use: https://chmod-calculator.com/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...