Sunday 23 September 2012

FreeBSD add a user to group


You need to use pw command. The pw utility is a command-line based editor for the system user and group files, allowing the superuser an easy to use and standardized way of adding, modifying and removing users and groups. First login as the root using su or sudo command.
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 animesh 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 ani -G sales
# passwd ani
First command adds user ani to secondary group called sales. Second commands set a password for ani.
Further readings:
=>Read pw command man page.