{"id":3747,"date":"2017-09-30T00:14:21","date_gmt":"2017-09-29T20:14:21","guid":{"rendered":"https:\/\/nayarweb.com\/blog\/?p=3747"},"modified":"2017-09-30T00:14:21","modified_gmt":"2017-09-29T20:14:21","slug":"unix-root-denied-permission-to-modify-files","status":"publish","type":"post","link":"https:\/\/nayarweb.com\/blog\/2017\/unix-root-denied-permission-to-modify-files\/","title":{"rendered":"UNIX: Root denied permission to modify files"},"content":{"rendered":"<p>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&#8217;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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3748\" src=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-29-at-23.42.50.png\" alt=\"\" width=\"804\" height=\"484\" srcset=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-29-at-23.42.50.png 804w, https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-29-at-23.42.50-300x181.png 300w, https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-29-at-23.42.50-768x462.png 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/p>\n<p>However by doing so, I&#8217;d get a permission denied error:<\/p>\n<pre>root@apache:\/var\/www# chown -R www-data: nayarweb.com\r\nchown: changing ownership of 'nayarweb.com\/poweredbynayarweb.png': Operation not permitted\r\n<\/pre>\n<p>When you&#8217;re actually root, it&#8217;s not common to be denied rights to do stuffs. The files were owned by `nobody`.<\/p>\n<pre>-rwxrwxrwx  1 nobody nogroup 8.1K Oct  9  2013 poweredbynayarweb.png<\/pre>\n<p>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.<\/p>\n<p>I had to find to uid with which apache (`www-data`) was running inside the LXD container. In my case, it was 100033.\u00a0 Running the following command on my LXD host machine fixed the problem<\/p>\n<pre>chown -R 100033 \/var\/lib\/lxd\/...\/nayarweb.com\/<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 &hellip; <a href=\"https:\/\/nayarweb.com\/blog\/2017\/unix-root-denied-permission-to-modify-files\/\" class=\"continue-reading\">Continue reading <span class=\"screen-reader-text\">UNIX: Root denied permission to modify files<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[210],"tags":[236,208,235],"class_list":["post-3747","post","type-post","status-publish","format-standard","hentry","category-technology","tag-cloud","tag-lxc","tag-lxd"],"_links":{"self":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/comments?post=3747"}],"version-history":[{"count":2,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3747\/revisions"}],"predecessor-version":[{"id":3750,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3747\/revisions\/3750"}],"wp:attachment":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/media?parent=3747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/categories?post=3747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/tags?post=3747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}