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

前端 未结 4 1123
夕颜
夕颜 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 13:43

    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.

    0 讨论(0)
  • 2021-02-12 13:44
    $ 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.

    The easy way to temporarily be root is to run the command via sudo. ($ man 8 sudo)

    0 讨论(0)
  • 2021-02-12 13:49

    In order to perform chmod, you need to be owner of the file you are trying to modify, or the root user.

    0 讨论(0)
  • 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/

    0 讨论(0)
提交回复
热议问题