How to really add FreeBSD users to groups

Software

I’ve seen sites listing this as the way to add a FreeBSD user to a group:

# echo "DON'T DO THIS"
# pw usermod [username] -G [groupname]

You almost certainly don’t want to do this. This command removes you from every group except the one you’ve listed. This has grave implications if you were a member of wheel before, because now you can’t elevate to root.

Instead, you want this:

# pw groupmod [groupname] -m [username]

Author bio and support

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.