Stop usermod -G from accidentally nuking your user secondary groups

User & Group Management

Stop usermod -G from accidentally nuking your user secondary groups

🧩 The Challenge

You’ve probably been there: you need to add a dev user to the docker group, so you run usermod -G and suddenly they lose access to every other resource they actually needed, like sudo or audio. I’ve wasted a solid twenty minutes debugging permissions because I forgot the -G flag doesn’t behave like an append by default.

💡 The Fix

Use the append flag to add a group without wiping out the existing ones, or stick to gpasswd if you want to be safer about it. It’s the difference between a minor config tweak and an angry dev calling you because they can’t run anything.

usermod -aG docker <username>

⚙️ Why It Works

Adding that little -a tells the system to append the new group to the user’s existing list instead of overwriting the secondary group membership entirely. Without it, you are effectively telling the system that the user belongs only to the groups you listed on the command line.

🚀 Pro-Tip: Check the results immediately with the groups command to confirm the membership actually stuck before moving on.

Linux Tips & Tricks | © ngelinux.com | 8/8/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted