FreeBSD: How To Add, Delete Or Modify Users

Written 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

1. adduser

This is your go-to in FreeBSD for adding a new user. Couldn’t be simpler.

  • Type in sudo adduser.
  • 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 wheel, webcamd, vboxusers, etc. depending on your needs.
  • You’ll be asked which shell to use (default is sh). I recommend either bash or zsh (if you’ve installed it).
  • Set a password if you wish.
  • You can safely select defaults on everything else (home directory, etc.).

2. pw

To add a new user directly, use sudo pw useradd <username>.

Modify users

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 chpass command:

sudo chpass username

2. vipw

Instead of using chpass and going through the prompts, you can also just use vipw to edit the same values:

sudo vipw

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 id <username>.

3. pw

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>

Changing passwords

To change a user’s password, use the passwd command:

sudo passwd username

You can also run passwd as a user to change your own password.

Deleting users

1. rmuser

FreeBSD comes with a utility called rmuser.

Just run sudo rmuser <username>.

Select Y and again if you wish to delete their home directory as well.

2. pw

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.

View Archive