I have a server which has all of its users under their own user:group for example the user somename has a folder /home/somename and is chowned somename:somename.

Now, it seems that this user has a problem updating their Wordpress from the web and it keeps on asking for FTP details. I've traced the issue into the fact that www-data doesn't have access to the users files.

...sudo chown -R www-data wordpress/... 

How do I allow or add www-data into somename privileges?

  • Where are their wordpress files located? I assume in some directory under their home directory, but the ideas I have depend on a specific directory location. – dafydd Dec 27 '12 at 17:18

In the 1970's world of /etc/passwd and /etc/group security, only a uid (user) can belong / be added to a group, no nesting is supported, but you could run something along the following lines, as a work around (assumes the wordpress directories are off the users home):

sudo bash
ls -d /home/* | xargs chmod o+rx
find /home/ -type d -name 'wordpress' | xargs chgrp -R www-data
find /home/ -type d -name 'wordpress' | xargs chmod -R g+rw

Which has the side effect of allowing all users to look in the home directory of any other user.

Alternatively you could add the wwwrun user id (change to suit) to the personal group of every user with a wordpress directory e.g.

sudo bash
for wpDir in `find /home -type d -name 'wordpress'`
  chgrp -R www-data $wpDir && chmod -R g+rw $wpDir
  wpUser=$(echo $wpDir|sed 's:/[^/]*/\([^/]*\)/.*$:\1:')
  grep $wpUser /etc/passwd > /dev/null && ( usermod -a -G $wpUser wwwrun; chmod g+rx /home/$wpUser)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy