I am completely new to a Linux operating system and was trying to setup Owncloud to use as a file server. I need to copy the owncloud folder into /var/www/ as an example but every folder on my system I am denied access to other than folders within my home folder. I am logged in as administrator but it tells me I am not the owner and do not have permission to access or make changes to any of the other folders. Any help with this would be greatly appreciated.
3 Answers
You need to take ownership of the directories you want to access.
Open terminal
sudo -s
hit enter and authenticate
chown -hR root /u
(change root to the username you want to take ownership) (u is the file path)
Here is an example:
chown -hR username /home/username/.config/ibus
The syntax -hR
takes ownership of subfiles and folders too!
Remember command line in linux IS case sensitive.
Why did I lose 2 points for answering this question correctly? It is 100% correct on the money, you just need to take care with which directories you take ownership of as it can cause security issues!

- 590
-
You are correct that changing ownership would allow access. However, Changing who owns the files/directories can break other processes that might need access. A better solution would be to See which group has access and add the current user to that group. – jmunsch Nov 16 '14 at 21:53
-
-
1From my previous comment: "Changing who owns the files/directories can break other processes that might need access." ... doing a recursive chown is ONLY partially correct. Which makes it 100% wrong.... MySQL for example? – jmunsch Nov 17 '14 at 17:04
-
I like what you're trying to say, but you're just not warning people enough that what you're doing might be dangerous. – RobotHumans Nov 17 '14 at 23:46
-
To install Owncloud on ubuntu properly please follow instruction here: http://www.howtoforge.com/how-to-install-owncloud-7-on-ubuntu-14.04
Also you can access files that are normally denied by running the file manager as root and you can access any folder you like.****Take caution when using this file manager****
Press Alt+F2
then type in
gksudo nautilus
It will ask for your password then you are free to use everything in your computer.
Or do it via terminal first Open terminal
ALT + CTRL + T
copy and paste this code
gksudo nautilus

- 231
-
- gksudo is no longer a default.
- if you don't understand the ramifications of operating as root, you definitely shouldn't be doing it.
– RobotHumans Nov 17 '14 at 23:48 -
Can you please ellaborate or guide me in the right direction to why gksudo is not a defualt way ?, or why it should not be used ? . I dont wanna guide people in the wrong direction or myself, but doing this has saved me lots of headaches in the past. – Brandd Newman Nov 18 '14 at 03:23
-
gksudo has been removed from the default install and may be removed at some point altogether... so you shouldn't recommend something that is on the chopping block. – RobotHumans Nov 18 '14 at 05:41
Best way to do it is to copy needed files as root
sudo cp -r ORIGIN DESTINATION
You also can change folder owner to yourself with
chown USER.GROUP DIRECTORY
or give write access to it to everyone with
chmod 777 DIRECTORY
These are more dangerous, be careful when doing this and use only with no outer access to the directory.
If you feel yourself better when working with GUI, you can try launching your file manager as root,
sudo nautilus
for example. Again - be very careful. This behaviour was intended to help reduce human errors.

- 2,213
- 1
- 22
- 29

- 365
-
cp -r
to change permissions would not be the best way to do it. Neither wouldchmod 777
. Also you can use backticks to quote code, and create code blocks by writing code and then highlighting it and pressingctrl
+k
– jmunsch Nov 14 '14 at 15:59 -
@jmunsch the big question was "I need to copy the owncloud folder into /var/www/ as an example but every folder on my system I am denied access", so what's wrong with using
sudo cp -r
for that? And I specifically mentioned that chown and chmod are dangerous. – user3901453 Nov 15 '14 at 16:25 -
It would be better to see which group has access to the directory with
ls -ld directoryname
and then give the current user permissions by adding them to that group. I guess if the folder is owned by root you would be correct. And using the 777 flag is generally frowned upon. Setting the permissions to what only is needed is generally more secure, something like 655 or something similar. Usingchmod 655 -R dirname
by usingsudo cp -r
the files and folders inherit the same permissions as the parent directory and it doesn't really resolve the user permissions. – jmunsch Nov 16 '14 at 21:18 -
2NEVER do
chmod 777
. This case of this user is/var/www
, or some directory outside of their/home/
such as another user's home or a system folder. Runningchmod 777
on ANY of those directories or those files is *dangerous* and opens you to security risks. – Thomas Ward Nov 17 '14 at 22:54
ls -ld /path/to/dirname
for the directories that are causing the issue? Sounds like a permissions issue: http://en.wikipedia.org/wiki/File_system_permissions – jmunsch Nov 14 '14 at 15:57