0

I have a folder located in /var/www that I am trying to move to my user's home directory.

I initially ran mv folder/ ~, and received a permissions denied error. I thought I had set the permissions up correctly, but to be sure I ran sudo chown -R folder/ user where user was my current user. I then ran chmod -R u=rwx folder/ to give myself write and read permissions (or whatever mv might require). However, even after trying to run mv again, I still lacked permissions.

What might cause this?

Full log of me repeating the above process:

webserver@testingweb:/var/www$ ls -la
total 12
drwxr-xr-x  3 root      root      4096 Mar 18 10:29 .
drwxr-xr-x 14 root      root      4096 Mar 18 10:13 ..
drwx------  4 webserver webserver 4096 Mar 18 10:44 website
webserver@testingweb:/var/www$ sudo chown -R webserver website/
webserver@testingweb:/var/www$ ls -la
total 12
drwxr-xr-x  3 root      root      4096 Mar 18 10:29 .
drwxr-xr-x 14 root      root      4096 Mar 18 10:13 ..
drwx------  4 webserver webserver 4096 Mar 18 10:44 website
webserver@testingweb:/var/www$ chmod -R 700 website/
webserver@testingweb:/var/www$ ls -la
total 12
drwxr-xr-x  3 root      root      4096 Mar 18 10:29 .
drwxr-xr-x 14 root      root      4096 Mar 18 10:13 ..
drwx------  4 webserver webserver 4096 Mar 18 10:44 website
webserver@testingweb:/var/www$ mv website/ ~
mv: cannot move 'website/' to '/home/webserver/website': Permission denied
webserver@testingweb:/var/www$

Edit: Interestingly enough, when I tried to move subdirectories and files individually it succeeded without any problems:

webserver@testingweb:/var/www$ cd website/
webserver@testingweb:/var/www/website$ ls
git  reproot
webserver@testingweb:/var/www/website$ mv git/ ~/website/
webserver@testingweb:/var/www/website$ ls
reproot
webserver@testingweb:/var/www/website$ mv reproot/ ~/website/
webserver@testingweb:/var/www/website$ ls
webserver@testingweb:/var/www/website$ 
3

You have write permissions over /var/www/website, but you don't have write permission over /var/www. In order to move /var/www/website to anywhere you need write permission over /var/www.

  • (+1) That makes sense, thank you – DreamConspiracy Mar 18 '18 at 22:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.