Stop usermod from locking you out of your own account

User & Group Management

Stop usermod from locking you out of your own account

🧩 The Challenge

Trying to add a user to a supplementary group is usually fine until you accidentally use -G instead of -aG. You’ll instantly strip the user of every other group membership they had, which is a nightmare if they were in sudo or docker.

💡 The Fix

Always stick to the append flag so you don’t accidentally wipe out existing group lists. It keeps your user in their current groups while adding the new one.

usermod -aG groupname username

⚙️ Why It Works

Adding that lowercase ‘a’ tells the system to append the new group to the existing list rather than overwriting the entire entry in /etc/group. If you forget it, the user disappears from their current groups faster than you can blink.

🚀 Pro-Tip: Run groups username before and after just to make sure you didn’t accidentally nuke their access.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted