Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I copied a folder recursively from the /www/ directory to one of my directories under my home directory. Now, every time I want to create a file or a folder in this copied directory, it says permission denied. So, I have to use sudo every time.

The problem is that I can create files/folders in other directories under the home directory, except this one. I tried changing the permission of this directory recursively to 755 but still the same problem.

Can anyone point out what the exact problem I am facing is? And how do I get around this?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The folder, quite obviously, is property of the root user, which is why you have to use sudo in order to interact with the folder. I don't think chown is able to apply permission changes to a folder, so you would have to go for the graphical route, as explained below.

[EDIT] A folders location typically doesn't affect it's permissions level or owner. For example, I could be the owner of a folder sitting in /usr/share/, but root could be the owner of a folder on my desktop. If you're wondering why it is this way, I'd say ask Bell Labs. They started it. :)

(I used Nemo, but the steps are the same for Nautilus)

First, open a terminal and type sudo nautilus (again, I used Nemo, but it's the same procedure), and enter your sudoer's password.

sudo nautilus (in this case, nemo)

When Nautilus opens, navigate to the folder you wish to change permissions on. Depending on what program you use, you may see and "Elevated Privileges" notice. This is to remind the user to be careful with what they do, as root permissions could damage the computer if used the wrong way.

Navigate to the folder desired

Now right click the folder you want to change and choose "Properties" go to the "Permissions" tab, and it should look something like this:

Root permissions on folder

Select the dropdown menu for Owner and Group, and change them from "root" to your username (in my case, ben). It should look like this now:

How it should look

If desired, click "Apply Permissions to Enclosed Files". Then close Nautilus and exit the terminal.

share|improve this answer
    
as soon as i right click and select properties, it throws this error : ERROR:nautilus-properties-window.c:1837:schedule_owner_change_timeout: assertion failed: (NAUTILUS_IS_FILE (file)) –  kevin Feb 5 at 19:12
    
The problem was duplicated on my side as well. I'll report it, but for the time being, issue sudo apt-get install nemo from a terminal. Let it install and try again, using sudo nemo in place of sudo nautilus. –  Sil Feb 5 at 19:16
    
I guess a command line solution would have been easier as I had to manually change the ownership of all the individual files manually. Thanks anyways! –  kevin Feb 5 at 19:24

Use this command to recursively change the ownership in the target directory:

sudo chown <username>:<groupname> -R /path/to/target

(..username and groupname are usually the same.)

e.g.

sudo chown kevin:kevin -R /home/kevin/target_directory

Now if you need, you may also set the permissions with chmod:

find /path/to/target -type f -execdir chmod 666 -Rv {} +

(which gives owner, group and the world RW permissions for all the files in the target.)

find /path/to/target -type d -execdir chmod 777 -Rv {} +

(which gives owner, group and the world RWX permissions for all the directories in the target.)

share|improve this answer
    
That helped a lot Thanks! –  kevin Feb 5 at 19:23

There is a possibility that when you copy www from /var/www it creates a link or symlink with /var/www.

Although try 777 permission or 777-755 = 022

share|improve this answer
    
Nope, I checked it and its not a symlink. –  kevin Feb 5 at 18:59
1  
The problem is file ownership, not file permissions. sudo chown -R username path/of/folder will do the trick. (Of course you need to replace "username" with your actual username and the same for path/to/folder) –  hmayag Feb 5 at 19:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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