正常的chmod是什么?
在我的网络服务器上,我的文件权限到处都是,我想将所有内容“重置”回原来的状态。 我不希望任何用户能够进入并删除我的网络服务器上的内容! 我只是希望他们能够查看 php 页面等。
我应该使用什么 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
以下是我收集的摘要:
用法:
chmod;
说明:
ls -l
查看组)和其他人( public)能够读取该文件,但不能执行或写入该文件(权限号 4)。还有一个交互式在线计算器,您可以使用它来确定要使用的权限:https://chmod-calculator.com/
Here's a summary that I have gathered:
Usage:
chmod <number> <filename>
Explanations:
ls -l
) and everyone else (the public) are able to read the file, but not execute or write to it (permission number 4).There's also an interactive online calculator you can use to figure out what permissions to use: https://chmod-calculator.com/
它们应该尽可能受到限制,但不能超过。
通常
0644
是一个不错的选择,它赋予所有者读写权限,但其他人只能读取。0755
用于目录。 但是,它可能取决于您的特定系统设置。They should be as restrictive as possible, but no more.
Usually
0644
is a good choice, which gives the owner read and write rights, but everybody else only read.0755
for directories. But, it can depend on your specific system settings.如果您想重置所有内容,请执行此命令并解决后果。 通常 644 对于文件来说是一个很好的权限,而 711 对于目录来说是一个很好的权限。 如果您允许目录列表,则使用 755。
如果您想要侵入性较小的内容,则只需删除组和“其他”的写入位即可。
If you want to reset everything, do this command and sort out the consequences. Usually 644 is a good permission for files and 711 is for directories. If you allow directory listings, then use 755.
If you want something less invasive, then just remove the write bits for group and "other".
我认为
644
是文件的标准,755
是目录的标准。I think
644
is standard for files and755
for directories.如果您的网络服务器仅提供网页服务,而不允许通过(例如)匿名 FTP 进行访问,则不正确的文件权限将不允许用户删除文件。
如果其他人可以通过其他方式(例如 SSH)访问您的服务器,请确保没有为您以外的用户设置写入位。 执行:
该命令将限制执行该命令的所有文件和目录的权限。
If your webserver serves only webpages, without allowing access through (e.g.) anonymous FTP, then incorrect file permissions do not allow users to remove files.
If other people have access to your server through other means (e.g. SSH), then make sure that the write-bit is not set for users other than yourself. Execute:
This command will restrict the permissions of all files and directories in which it is executed.
无论您使用哪种方法,如果您的 Web 应用程序有可能依赖具有特定权限的文件或目录,请务必进行彻底的测试。 虽然允许过于宽松的权限可能是糟糕的设计,但有时确实会发生这种情况,因此您可能会破坏应用程序。
Whichever approach you use, be sure to do some thorough testing if there is any chance that your web application relies files or dirs having certain permissions. While allowing too permissive permissions is probably bad design, this does happen sometimes, so you might break the application.