How to add users on FreeBSD using adduser or pw

I am a new FreeBSD system administrator. How do I add users on FreeBSD Unix operating systems using command line?

FreeBSD is Unix like general-purpose operating systems. FreeBSD provides various tools to add, modify, and remove local user accounts using the CLI. This page shows how to add users on FreeBSD operating systems using useradd and pw commands.

Add users on FreeBSD

The procedure is as follows:

  1. Open the terminal app
  2. Switch to root user account using sudo -i OR su -
  3. Run adduser command for adding new users on FreeBSD interactively
  4. Delete user using rmuser command

Let us see all examples in details. First, list all shells on system using the grep command:
grep '/bin/' /etc/shells

Creating FreeBSD users from the command line using adduser

Log in as root user using the sudo command/su command:
sudo -i
Create the vivek user on FreeBSD, run:

How To Add Users on FreeBSD

Adding a user on FreeBSD using adduser command

Confirm that user exists in the system

Run the following cat command or grep command/egrep command:
cat /etc/passwd
tail -1 /etc/passwd
grep '^username' /etc/passwd
grep '^vivek' /etc/passwd

Confirm that FreeBSD users exists in the system

Confirm that FreeBSD users exists in the system using various commands

Please note that the /etc/passwd files stores user names and other information. The /etc/passwd file is generated from the /etc/master.passwd file by pwd_mkdb command.

How do I change or set the password for vivek user

Run the passwd command as follows:
passwd vivek
Change or set password for users on FreeBSD

FreeBSD allow sudo privileges for user

Make sure sudo is installed on FreeBSD and wheel group is allowed as follows:
# visudo
Sample outputs:

## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

Save and close the file. Any FreeBSD user who is a member of the wheel group can run a command using sudo. Use the id command to find out if vivek is part of wheel group
# id -Gn vivek
vivek wheel

If not add user vivek to the wheel group, run:
# pw groupmod wheel -m vivek
Verify it using the /etc/group file
# id -Gn vivek
# grep '^wheel' /etc/group

FreeBSD Grant Sudo Privileges Using wheel group

How to delete or remove user account

The rmuser command removes one or more users submitted on the command line or from a file in FreeBSD operating system. Run:
# rmuser username
# rmuser
## delete user named marlena
# rmuser marlena

Delete the FreeBSD user along with any personal data of the user

Delete the FreeBSD user along with any personal data of the user

Confirm that marlena user is successfully deleted from FreeBSD box:
grep '^marlena' /etc/passwd
cat /etc/passwd
id marlena

Sample outputs:

id: marlena: no such user

How to use pw command

The pw command create, remove, modify & display system users and groups. It has many more options. For example:
pw user help
pw user add help
pw user del help
pw user mod help
pw group help
pw lock help
pw unlock help

In this example, add user named marlena as follows:
# pw user add -n marlena -c 'Marlean Root' -d /home/marlena -G wheel -m -s /usr/local/bin/bash

  • -n marlena : login name
  • -c 'Marlena Root' : user name/comment
  • -d /home/marlena : home directory
  • -G wheel : additional groups (add to wheel group)
  • -m : create and set up home
  • -s /usr/local/bin/bash : name of login shell

One can local and unlock FreeBSD user using the pw command:
# pw lock marlena
# pw unlock marlena

See pw command man page for more info:
man pw


This page demonstrated how to create several users on your FreeBSD Unix box, set passwords for those users, and delete them if the need arises using various commands.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

  • 🐧 Vivek Gite Sep 22, 2019 @ 20:02

    Have a question? Need help adding a new users to FreeBSD? Post it to our forum thread.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum