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.

Hello and apologies if this has been asked...I couldn't find the answer easily.

I am using Ubuntu Server 12.04

I can't write to a directory where my user should belong to the directory's group...

total 12
-rw-rw-r-- 1 www-data root   30 Sep 17 13:34 index.php
drwxrwxr-x 7 www-data root 4096 Sep 17 13:34 twentyeleven
drwxrwxr-x 4 www-data root 4096 Sep 17 13:34 twentyten

dp : dp adm cdrom sudo dip www-data plugdev lpadmin sambashare www-pub

Here is the updated listing...

-rw-rw-r-- 1 www-data root   28 Sep 17 13:34 index.php
drwxrwxr-x 3 www-data root 4096 Sep 17 13:34 plugins
drwxrwxr-x 4 www-data root 4096 Sep 17 13:34 themes
dp@acme:/var/www/stlit/wp-content$ cd themes
dp@acme:/var/www/stlit/wp-content/themes$ ls -la
total 20
drwxrwxr-x 4 www-data root 4096 Sep 17 13:34 .
drwxrwxr-x 4 www-data root 4096 Sep 17 13:34 ..
-rw-rw-r-- 1 www-data root   30 Sep 17 13:34 index.php
drwxrwxr-x 7 www-data root 4096 Sep 17 13:34 twentyeleven
drwxrwxr-x 4 www-data root 4096 Sep 17 13:34 twentyten

I am a noob to Ubuntu so I am sure this is a mistake on my part. Please let me know if I need to provide more information.

share|improve this question
2  
Please provide a complete directory listing by ls -al (this includes the . and ..) and the output of the command id. My best guess now is that you're not in the root group (you shouldn't) and that you want to change the group of the directory to one you're in. –  gertvdijk Sep 17 '12 at 19:54
add comment

2 Answers 2

up vote 1 down vote accepted

According to the listing above

drwxrwxr-x 4 www-data root .....

This means, that the first name www-data is the "owner" of the file, and the second one root is the "group" the file belongs to.

And since your user isn't in the root group (and it shouldn't!), you cannot modify the file, as only the owner and group have full access on the files.

  1. To change the group of a file you need to use

    sudo chgrp "new-group-name" file
    
  2. To change the owner of a file you need to use

    sudo chown "new-owner-name" file
    
  3. If you want to change both, you can do it in a single command with:

    sudo chown "new-owner-name":"new-group-name" file
    

My best guess is that you needed to use chgrp but instead you used chown

share|improve this answer
    
I think you are correct! As I said I am a newbie...thank you! –  dpbklyn Sep 18 '12 at 16:40
    
Sorry for the delay...I am just testing this now... –  dpbklyn Sep 19 '12 at 16:05
add comment

If you mean either of twentyeleven or twentyten in that file listing, the group there is root, and the user is www-data, who owns those directories.

You will need to change the group of the files to the www-data group as well if you wish to write to them as that user. You probably want to do sudo chgrp -R www-data . in the directory containing those files and directories you want to edit as your user.

share|improve this answer
    
Thank you, I added some more information above... –  dpbklyn Sep 18 '12 at 14:04
add comment

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.