How to Create User with useradd in FreeBSD

You can invoke “adduser” command in FreeBSD in order to create new user. Adduser will prompt you for user info like name, uid, gid, shell environment and etc. But sometime we would like to create user access through Bash script. “useradd” command is the good way to do it.

In Linux, using “useradd” is pretty common for creating new user access. You can also use “useradd” in FreeBSD, but not directly invoke “useradd” command. Below is the sample of creating new user in FreeBSD with “useradd”.


shell> pw useradd cheryl -c 'Cheryl Windows Admin' -d /home/cheryl -s /usr/local/bin/bash

New user account is created, but don’t forgot to set password for the account


shell> passwd cheryl

You can run other command like “userdel”, “usermod”, “usershow”, “groupadd”, “groupdel”, “groupmod”, “lock”, “unlock” on FreeBSD by using the “pw” command.