44

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
...
0

1 Answer 1

56

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
Password: 
$ groups
sys lp wheel optical scanner terdon
1
  • 28
    In my case, it wasn't just logging out. I had to RESTART. Just in case it helps others! +1
    – 8bitjunkie
    Commented Feb 21, 2018 at 12:43

Not the answer you're looking for? Browse other questions tagged .