FreeBSD: How To Add, Delete Or Modify UsersWritten by: Donovan / Last updated: Mar 4, 2023
So you want to add a new user in FreeBSD or edit an existing user?
Here’s a quick guide on the different ways to do this.
Adding new users
This is your go-to in FreeBSD for adding a new user. Couldn’t be simpler.
- Type in
- Follow the prompts to set the user information.
- One of the prompts will ask if you want to invite the user to any groups. Here you can add the user to groups like
vboxusers, etc. depending on your needs.
- You’ll be asked which shell to use (default is
sh). I recommend either
zsh(if you’ve installed it).
- Set a password if you wish.
- You can safely select defaults on everything else (home directory, etc.).
To add a new user directly, use
sudo pw useradd <username>.
1. Get back to the initial prompts to change user info
To get back to the initial prompts used when creating a user and modify their info, use the
sudo chpass username
Instead of using
chpass and going through the prompts, you can also just use
vipw to edit the same values:
This will open a text file using
vim allowing you to directly edit these values on each user.
You can verify these changes by typing
pw can do pretty much anything - add, modify and delete users.
- To modify a user, use
sudo pw usermod <username> <flags>(
-c= full name,
-d= home directory,
-s= shell). There’s so much you can do with
pw, so I recommend consulting the manpage .
- To add a user to a group, use
sudo pw groupmod <group> -m <username>
To change a user’s password, use the
sudo passwd username
You can also run
passwd as a user to change your own password.
FreeBSD comes with a utility called
sudo rmuser <username>.
Y and again if you wish to delete their home directory as well.
You can also use
pw with this command:
sudo pw userdel <username>.
Locking and unlocking users in FreeBSD
To lock a user, type
sudo pw lock <username>.
To unlock a user, type
sudo pw unlock <username>.
Alternatively, you can edit the
/etc/master.passwd file and prepend
*LOCKED* to the user to lock their account.