Why is "usermod -a -G" not adding my user to the group?

I'm using Ubuntu 18.04. I want to add my user, "davea" to the group "www-data". I tried this

(venv) davea@chicommons-laboratory:/var/www/html/web$ groups
davea sudo
(venv) davea@chicommons-laboratory:/var/www/html/web$ sudo usermod -a -G www-data davea
[sudo] password for davea:
(venv) davea@chicommons-laboratory:/var/www/html/web$ groups
davea sudo

but as you can see, even though the command didn't give any errors, my user is still not added to the group. What am I doing wrong?

3 Answers

your command is good. you can check the group with

getent group | grep davea

if your user are in group www-data, you just have to relog your user davea.

regards

You need to log off and on the davea user to see that davea is a member of www-data group.

Or you can use newgrp

From manpage

The newgrp command is used to change the current group ID during a login session. If the optional - flag is given, the user's environment will be reinitialized as though the user had logged in, otherwise the current environment, including current working directory, remains unchanged.

newgrp - www-data 

I use this in Live-sessions; where you usually you can not logput for reloging.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like