How to add users/groups to a FreeBSD System?

Question: How do I add a user and group to my FreeBSD System?

You can use the 'pw' command to add a user and or group to the FreeBSD System.
The 'pw' command is a program that will allow any user with superuser priveledges
to edit and or add users and groups on FreeBSD with ease. It also allows you a way
to standardize modification of adding and removing users and groups.


You will want to be logged in as root and or a user with sudo access.

# pw groupadd adminusers

This would create the group 'adminusers' to the machine.

Now say you want to add the users 'mike' to the adminusers using pw

# pw useradd mike -s /bin/csh -g adminusers

This command would create the user mike, with a shell of /bin/csh and add it to the adminusers groud.
The user would also have his home directoryu under /home/mike

Now say you want to have this user's home directory on a different partion, for example /mnt/disk2/home

#pw useradd mike -d /mnt/disk2/home/mike -s /bin/csh/ -g adminusers

Now say that you want to add mike to a secondary group on the system say a group that has been created already called 'ftpusers'
To do this you would want to do the following

#pw usermod mike -G ftpusers

Say you want to add mike to multiple groups at the same time.

#pw usermod mike -G ftpusers,wwwusers,sales

External Links:
http://www.freebsd.org/cgi/man.cgi  (FreeBSD man pages)
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ (FreeBSD handbook)

Was this helpful?