@devf
Linux Oct 15, 2026

Adding an existing user to a group in Linux

Set up a second user on my Ubuntu box and need them in the docker group. I don't want to remove them from their other groups by accident. What's the right command?
1

Leave A Reply

Log in to post an answer.

1 Answer

abhishek87 Oct 20, 2026
devf
sudo usermod -aG groupname username Don't forget the -a. Without it, -G replaces all the user's other groups with just that one, which is how people lock themselves out of sudo. The change only applies after the user logs out and back in.