I use Ubuntu 12.04. I am trying to add the user gefalko to the www-data group. I use

root@xxx~# usermod -a -G www-data gefalko

If I understand correctly, I should now see www-data in the output of groups when run by gefalko:

gefalko@xxx:~$ groups

However, there is no www-data in the output:

gefalko adm cdrom sudo dip plugdev lpadmin sambashare

I want to edit index.php owned by www-data, but I can't (permission denied):

gefalko@xxx:/var/www/html/projectx$ ls -l
total 1320
-rwxrwxr-x  1 www-data www-data    1613 Bal 18 10:18 index.php

When changing a user's groups, the changes don't take effect until the next time the user logs in. So, you can either log out and log back in again or start a new login shell as gefalko:

$ groups
sys lp wheel optical scanner terdon
terdon@oregano ~ $ sudo usermod -a -G www-data terdon
terdon@oregano ~ $ groups
sys lp wheel optical scanner terdon   ## no change

$ su terdon -   ## start a new login shell
$ groups
sys lp wheel optical scanner terdon
  • 6
    In my case, it wasn't just logging out. I had to RESTART. Just in case it helps others! +1 – 8bitjunkie Feb 21 '18 at 12:43
  • how tedious, what is this... windows 95 :speak_no_evil: – Jacob Stanley Aug 13 '19 at 22:12

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