FreeBSD: Delete User Account Command

How do I remove the tom user under FreeBSD operating system using command line options?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements pw+FreeBSD
Est. reading time N/A
You need to use the pw comamnd. It is a command-line based editor for the system user and group files, allowing the superuser an easy to use and standardized way of adding, modifying and removing users and groups.


The syntax is as follows to remote the user account under FreeBSD operating systems:

pw deluser user-name-here
pw userdel user-name-here


To delete or remove tom user account from the system, enter:
# pw userdel tom

Removing home directory and other files

The -r option tells pw command to remove the user’s home directory and all of its contents. From the pw man page:

The pw utility errs on the side of caution when removing files from the system. Firstly, it will not do so if the uid of the account being removed is also used by another account on the system, and the ‘home’ directory in the password file is a valid path that commences with the character /. Secondly, it will only remove files and directories that are actually owned by the user, or symbolic links owned by anyone under the user’s home directory. Finally, after deleting all contents owned by the user only empty directories will be removed. If any additional cleanup work is required, this is left to the administrator. Mail spool files and crontabs are always removed when an account is deleted as these are unconditionally attached to the user name. Jobs queued for processing by at are also removed if the user’s uid is unique and not also used by another account on the system.

To delete jerry user account and home directory from the system, enter:
# pw userdel tom -r

Use UID instead of username

The syntax is:

pw userdel UID-HERE 
pw userdel -u uid -r
pw userdel UID-HERE [options]
## delete user having UID # 333
pw userdel 333 -r

Type the following command to read the pw command man page:
$ man pw

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

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
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
2 comments… add one
  • M.S. Babaei Apr 10, 2013 @ 18:49

    What about “rmuser” command?

  • Chris Dec 23, 2014 @ 7:45


Leave a Reply

Your email address will not be published.

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