FreeBSD: Delete User Account Command

by on April 9, 2013 · 1 comment· LAST UPDATED April 9, 2013

in , ,

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

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
Requirementspw+FreeBSD
Estimated completion timeN/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.

Syntax

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

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

Examples

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 M.S. Babaei April 10, 2013 at 6:49 pm

What about “rmuser” command?

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: