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 have a problem understanding some aspects of file permissions. The situation is this:

I created a directory as /to using sudo and then changed it's permissions to drwxrwsr-x. I also changed the group for the directory to "xxx" which exists on my system. I am a member in good standing of group "xxx". My understanding is that I should be able to create files and directories in /to since I am a member of group "xxx".

However when I run the following command I get permission denied when trying to create each file and directory in /to.

cp -r from/* /to

What am I not understanding about this situation? I can obviously fix this particular instance with sudo or by changing the owner, but I want to understand the principles.

Command output

jgossage@Hector:~$ cp -r Downloads/* /Downloads
cp: cannot create directory /Downloads/Eclipse': Permission denied
cp: cannot create regular file /Downloads/google-chrome-stable_current_amd64.deb':
Permission denied
cp: cannot create directory /Downloads/Kindle': Permission denied
cp: cannot create directory /Downloads/WindowsDlls': Permission denied
#Target directory information
jgossage@Hector:~$ ls -al /Downloads
total 8
drwxrwsr-x 2 root admins 4096 Feb 13 07:16 .
drwxr-xr-x 28 root root 4096 Feb 14 08:23 ..
jgossage@Hector:~$
share|improve this question
    
Are you moving files from the root / directory? –  Tom Brossman Feb 14 '13 at 20:43
    
No, from a sub-directory in my home directory. –  Jonathan Feb 14 '13 at 20:46
1  
It would be helpful if you didn't try to edit/hide your actual situation (by using /to, xxx and so on). Please tell us the real commands and the real output you get - use copy&paste and put it into your question. –  guntbert Feb 14 '13 at 21:12

1 Answer 1

Looking at the permissions you set I don't think you have granted "others" permissions to write to the directory. Looking at the permissions you've granted

drwxrwsr-x

I'm pretty sure that breaks down as:

type: d
owner: rwx (Read/Write/Execute)
group: rws (Read/Write/Special)
all/others: r-x (Read and Execute)

Since the folder was created as root (sudo) only the root user has access to write to the folder (although as a user you can read the contents of the directory).

I think to fix the problem you should be able to run:

sudo chmod o+w /to

Naturally replacing /to with the real folder name/path. This will give ALL users write access to the folder which is probably not ideal. Alternatively you can take ownership of the folder (and all files within the folder):

sudo chown -R jgossage /to

Again replacing /to with the real folder name/path. This should keep the directory permissions the same (drwxrwsr-x) which would mean that the owner would have read/write/execute permissions but other users would only have read and execute permissions.

share|improve this answer

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.