php 在运行时错误时通过 chmod 更改权限并显示“不允许操作”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1592303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing permissions via chmod at runtime errors with "Operation not permitted"
提问by Deepak
When I use chmod()to change permissions at run time, it gives me the below message:
当我使用chmod()在运行时更改权限时,它给了我以下消息:
Warning: chmod() [function.chmod]: Operation not permitted in /home/loud/public_html/readalbum.php
警告:chmod() [function.chmod]:在 /home/loud/public_html/readalbum.php 中不允许操作
How can I remove this error and make the chmodfunction work?
如何消除此错误并使该chmod功能正常工作?
回答by DigitalRoss
$ sudo chmod ...
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.
您需要是文件的所有者或超级用户,即用户root。如果您拥有目录但不拥有文件,则可以复制文件,rm 原始文件,然后将其 mv 返回,然后您就可以 chown 了。
The easy way to temporarily be root is to run the command via sudo. ($ man 8 sudo)
暂时成为 root 的简单方法是通过 sudo 运行命令。($ man 8 sudo)
回答by Martin v. L?wis
In order to perform chmod, you need to be owner of the file you are trying to modify, or the root user.
为了执行 chmod,您需要是您尝试修改的文件的所有者,或者是 root 用户。
回答by Charles Merriam
This is a tricky question.
这是一个棘手的问题。
There a set of problems about file permissions. If you can do this at the command line
有一系列关于文件权限的问题。如果您可以在命令行执行此操作
$ sudo chown myaccount /path/to/file
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 -lthe 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:
如果您无法获得权限,那么您可能已经安装了 FAT-32 文件系统。如果您ls -l找到该文件,并且发现它由 root 拥有并且是“plugdev”组的成员,那么您肯定是它的问题。FAT-32 权限在挂载时设置,使用 /etc/fstab 文件的行。您可以像这样设置所有文件的 uid/gid:
UUID=C14C-CE25 /big vfat utf8,umask=007,uid=1000,gid=1000 0 1
Also, note that the FAT-32 won't take symbolic links.
另外,请注意 FAT-32 不会采用符号链接。
Wrote the whole thing up at http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/
在http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/写了整件事
回答by James Black
You, or most likely your sysadmin, will need to login as root and run the chown command: http://www.computerhope.com/unix/uchown.htm
您,或者很可能是您的系统管理员,需要以 root 身份登录并运行 chown 命令: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.
或者,您可以成为拥有此文件的组的成员,然后您可以使用 chmod。
But, talk with your sysadmin.
但是,请与您的系统管理员交谈。

