43

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
...
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Edgaras Karka
  • 2,447
  • 5
  • 15
  • 14

1 Answers1

55

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
terdon
  • 234,489
  • 66
  • 447
  • 667