FreeBSD: add or remove an user to a group

If you need to add an user to an existing group, or more than one, do:

pw usermod username -G group1,group2,group3

Remember that the user will be inserted ONLY in the groups that you have specified in the grouplist. If your user is in the wheel group and you do a -G ftp,games he’ll be removed from wheel and you’ll not be able to su- to root.

If you need to create a group:

pw groupadd groupname

If you need to see the users of a group:

pw groupshow groupname

If you need to remove an user from a group (for example, group2) you have to set a new list of groups and you’ve to know in which groups the user is currently:

id -Gn username
pw usermod username -G group1,group3

One thought on “FreeBSD: add or remove an user to a group

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *