Changing permissions via chmod at runtime errors with “Operation not permitted”

前端 未结 4 1126
夕颜
夕颜 2021-02-12 13:18

When I use chmod() to change permissions at run time, it gives me the below message:

Warning: chmod() [function.chmod]: Operation not permitt

4条回答
  •  青春惊慌失措
    2021-02-12 14:07

    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 -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:

    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.

    Wrote the whole thing up at http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/

提交回复
热议问题