UNIX: Root denied permission to modify files

WordPress notified me that an update was due. There are different ways to allow WordPress to update itself from the admin panel. One would be to use your FTP credentials (which I don’t have) and the other would be to give WordPress permission to edit its files i.e. give `www-data`, the user who run the web server, permission to read/write in /var/www.

However by doing so, I’d get a permission denied error:

root@apache:/var/www# chown -R www-data: nayarweb.com
chown: changing ownership of 'nayarweb.com/poweredbynayarweb.png': Operation not permitted

When you’re actually root, it’s not common to be denied rights to do stuffs. The files were owned by `nobody`.

-rwxrwxrwx  1 nobody nogroup 8.1K Oct  9  2013 poweredbynayarweb.png

Reading some stackoverflow posts, someone suggested that the files might not be owned by the OS as it might be mounted from a remote location. It is the source server who actually decides what could be done with the files. One common case of the scenario is mounting your files via NFS. Then I realised that my apache VM is actually an LXD container on a KVM host.

I had to find to uid with which apache (`www-data`) was running inside the LXD container. In my case, it was 100033.  Running the following command on my LXD host machine fixed the problem

chown -R 100033 /var/lib/lxd/.../nayarweb.com/

One thought on “UNIX: Root denied permission to modify files

Leave a Reply

Your email address will not be published. Required fields are marked *