在运行时出现“不允许操作”错误时通过 chmod 更改权限
当我使用 chmod() 在运行时更改权限时,它会显示以下消息:
警告:chmod() [function.chmod]:/home/loud/public_html/readalbum.php 中不允许操作
如何删除此错误并使 chmod 函数正常工作?
When I use chmod()
to change permissions at run time, it gives me the below message:
Warning: chmod() [function.chmod]: Operation not permitted in /home/loud/public_html/readalbum.php
How can I remove this error and make the chmod
function work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要是文件的所有者或超级用户,即用户root。如果您拥有该目录但不拥有该文件,则可以复制该文件,rm 原始文件,然后将其 mv 回来,然后您就可以 chown 它。
暂时成为 root 的简单方法是通过 sudo 运行命令。 ($
man 8 sudo
)You need to either be the owner of the file or be the superuser, i.e., user root. If you own the directory but not the file, you can copy the file, rm the original, then mv it back, and then you will be able to chown it.
The easy way to temporarily be root is to run the command via sudo. ($
man 8 sudo
)为了执行 chmod,您需要是尝试修改的文件的所有者,或者 root 用户。
In order to perform chmod, you need to be owner of the file you are trying to modify, or the root user.
这是一个棘手的问题。
存在一系列有关文件权限的问题。如果您可以在命令行执行此操作
,那么您就遇到了标准权限问题。确保您拥有该文件并有权修改该目录。
如果您无法获得权限,那么您可能安装了 FAT-32 文件系统。如果您
ls -l
该文件,并且发现它由 root 拥有并且是“plugdev”组的成员,那么您可以肯定这是问题所在。 FAT-32 权限是在安装时使用 /etc/fstab 文件行设置的。您可以像这样设置所有文件的 uid/gid:另外,请注意 FAT-32 不会采用符号链接。
将整个内容写在 http://www.charlesmerriam.com/blog/2009/12/operation-not-permission-and-the-fat-32-system/
This is a tricky question.
There a set of problems about file permissions. If you can do this at the command line
then you have a standard permissions problem. Make sure you own the file and have permission to modify the directory.
If you cannnot get permissions, then you have probably mounted a FAT-32 filesystem. If you
ls -l
the file, and you find it is owned by root and a member of the "plugdev" group, then you are certain its the issue. FAT-32 permissions are set at the time of mounting, using the line of /etc/fstab file. You can set the uid/gid of all the files like this:Also, note that the FAT-32 won't take symbolic links.
Wrote the whole thing up at http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/
您,或者很可能是您的系统管理员,需要以 root 身份登录并运行 chown 命令:
http://www.computerhope.com/unix/uchown.htm
通过这个命令您将成为该文件的所有者。
或者,您可以成为拥有此文件的组的成员,然后可以使用 chmod。
但是,请与您的系统管理员交谈。
You, or most likely your sysadmin, will need to login as root and run the chown command:
http://www.computerhope.com/unix/uchown.htm
Through this command you will become the owner of the file.
Or, you can be a member of a group that owns this file and then you can use chmod.
But, talk with your sysadmin.