How can I add an existing user to a group in FreeBSD? The command usermod does not work.


4 Answers 4


pw is the command you are looking for. To add user klaatu to the group foo, do:

pw groupmod foo -m klaatu

Here is the FreeBSD handbook page on the subject. It's an easy and informative read: Users and Basic Account Management


Wheel is famous for FreeBSD, if you want to need to use su command, you need to be member of wheel group, So pw groupadd get a groupName and -m get members of your group.Old style of the following command you needed to extra command.

pw groupadd wheel -m mohsen,ali,john,Hilary,Kate

The other answers are all good. This also works:

pw usermod john -G mygroup
  • 1
    But it will erase john from all other groups that he was previously in...
    – PePa
    Commented Apr 19, 2020 at 18:35

Task: Add existing user to group

You would like to add existing user tom to secondary group called ftpusers. Type the command as follows:

# pw usermod tom -G ftpusers

You can add tom to secondary group ftpuser and wwwusers:

pw usermod tom -G ftpusers,wwwusers

-G option Set the default groups in which new users are granted membership. This is a separate set of groups from the primary group, and you should avoid nominating the same group as both primary and extra groups.

Task: Add a new user to group

Add new user jerry to system and to secondary group sales:

# pw useradd jerry -G sales
# passwd jerry

First command adds user jerry to secondary group called sales. Second commands set a password for jerry.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .