I have owncloud running in Ubuntu server I have enabled external storage pointing to second hard drive in my machine and added a local storage

I can see the folder in owncloud but when I click on it I can see anything, empty

I need to fix the permissions (OC needs read and write permissions for www-data)

Run this command

sudo -u www-data ls -la /media/Test/Share/

I get

ls: cannot access /media/Test/Share/: Permission denied

How can I fix the permissions?

1 Answer 1


To change the owner of a file (or folder) you use chown (ChangeOwner). You can specify a user and a group as owner. As in,

chown option user:group file/folder

In the situation you a describing, you could try the following, only change the group to www-data, so that the original owner isn't affected.

chown -R :www-data /media/Test/Share

Please notice the : before www-data...

To change the user and group owner of the folder,

chown -R www-data:www-data /media/Test/Share

-R option is used for "Recursive", it will also change the user & group of the folders contents (as in, any other directory or file that it holds).

Also check this other answer, change-folder-permissions-and-ownership

This should do it.

Still, if the user or group don't have sufficient rights yet (read/write) you can use the chmod command for it.

I'll start with the warning...

Please, do not use the value 777 unless you know exactly what you are doing. Even then you should be wondering if it's worth it ;)

Read the following please: Why shouldn't /var/www have chmod 777

For instance, to give current user&group read/write rights on a file, but others none,

chmod 660 filename

See this article for more information on the values and a better explanation then I can give,


  • I have tried all that and still I can't see folders and files inside local storage added to my owncloud. When I run sudo -u www-data ls -la /media/Test/Share/ I get still ls: cannot access /media/Test/Share/: Permission denied
    – Carlos
    Mar 25, 2015 at 20:17
  • Not sure if you can use sudo in this manner with a system account. (not sure) As www-data probably does not have a shell specified for it. Still, this should work, 'sudo -u www-data /bin/bash -c ls -la /media/Test/Share' Else/Also please post the current "ls -al" of the folder in question.
    – Sinn3d
    Mar 25, 2015 at 20:31
  • Change Test folder name for carlos carlos@ubuntu:~$ sudo -u www-data /bin/bash -c ls -la /media/carlos/Share Desktop owncloud-8.0.0.tar.bz2 Release.key your.website.net.pem Documents owncloud8.tar.bz2 Templates Downloads Pictures Videos Music Public your.website.net.key
    – Carlos
    Mar 25, 2015 at 21:55
  • root@ubuntu:~# cd /media/carlos/Share root@ubuntu:/media/carlos/Share# ls -al total 16 drwxr-xr-x 4 www-data www-data 4096 Mar 25 19:49 . drwxr-xr-x+ 3 root root 4096 Mar 24 22:31 .. drwxrwxrwx 3 www-data www-data 4096 Mar 22 17:51 MyDrive drwx------ 4 www-data www-data 4096 Mar 25 19:17 .Trash-1000 root@ubuntu:/media/carlos/Share# ^C Still I can't see files in the local storage in onwcloud
    – Carlos
    Mar 25, 2015 at 21:57
  • Got it to work now. After I clean browser cache, folders just pop up Thanks for all your help Cheers
    – Carlos
    Mar 25, 2015 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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