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

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

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest