Adding user/group in a FreeBSD server

How do I add a user and group to the FreeBSD Server?:

The ‘pw’ command can be used to add a user and or group to the FreeBSD System. The ‘pw’ command is a program that will allow any user with superuser privileges to edit and or add users and groups on FreeBSD with ease. It also allows a way to standardize modification of adding and removing users and groups.

pw groupadd anewgroup

This would create the group ‘anewgroup’ to the machine.

Now to add a users ‘ben’ to the ‘anewgroup’ using pw, issue the following command.

pw useradd ben -s /bin/csh -g anewgroup

This command would create the user ben, with a shell of /bin/csh and add it to the anewgroup group. The user would also have his home directory under /home/ben.

Now say, if the user needs to have the home directory on a different partition, for example /mnt/test/home issue the following command.

pw useradd ben -d /mnt/test/home/ben -s /bin/csh/ -g anewgroup

If the user ‘ben’ is to be added to a secondary group on the system, say a group that has been created already called ‘oldgroup’, then execute the following.

pw usermod ben -G oldgroup

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.