FreeBSD: add or remove an user to a group

Published on: April 5, 2011
Tags: , , ,
Categories: BSD

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

Share this
No Comments - Leave a comment

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Welcome , today is Thursday, May 23, 2013