Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing permissions via chmod at runtime errors with "Operation not permitted"

Tags:

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?

like image 997
Deepak Avatar asked Oct 20 '09 03:10

Deepak


People also ask

How do I change operation not permitted?

“Operation not permitted” common causes The filesystem is not Linux-native (EXT, EXT2, EXT3, EXT4, JFS, Minix, ReiserFS, Reiser4, XFS) The file has the immutable flag set in its extended attributes. No root provileges. You need to be root to change the ownership of a file.

What does chmod 7777 mean?

7777 means that everyone regardless of who is accessing the system has access to read, write, and execute.

What is the meaning of chmod 666?

A text file has 666 permissions, which grants read and write permission to everyone. A directory and an executable file have 777 permissions, which grants read, write, and execute permission to everyone.


2 Answers

$ 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)

like image 174
DigitalRoss Avatar answered Oct 19 '22 07:10

DigitalRoss


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

like image 25
Martin v. Löwis Avatar answered Oct 19 '22 07:10

Martin v. Löwis