Permission denied to create files in particular directory under home directory

96

Solution 1

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.

Solution 2

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:
96

Related videos on Youtube

Stephen Carman
Author by

Stephen Carman

Updated on September 18, 2022

Comments

  • Stephen Carman
    Stephen Carman almost 2 years

    So elasticbeanstalk when updating or changing a docker deployed image will use docker kill in order to terminate the running docker container in order to be able to switch it for the new container that it is going to stage.

    I'd like to be able to capture the logging information from that container, but the container is sent a SIGKILL so I cannot directly have the container shutdown gracefully. I could hack the EB staging and deployment scripts to use docker stop instead of docker kill, but I'm confused why EB doesn't give me the chance to clean up the app first before shutting it down.

    I know it's a long shot, but is there anyway I can hook around this in order to be able to capture this log output outside of constantly pushing it off the machine? I don't really want to mess with amazon's deployment scripts, but that seems like the only way to get this functionality. Anyone have any insight into this?

  • kevin
    kevin over 10 years
    Nope, I checked it and its not a symlink.
  • kevin
    kevin over 10 years
    as soon as i right click and select properties, it throws this error : ERROR:nautilus-properties-window.c:1837:schedule_owner_chang‌​e_timeout: assertion failed: (NAUTILUS_IS_FILE (file))
  • ExplodingKittens
    ExplodingKittens over 10 years
    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.
  • hmayag
    hmayag over 10 years
    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)
  • Winnemucca
    Winnemucca about 7 years
    this changed it exactly as expected to show rxw but still blocked.