How do I remove the tom user under FreeBSD operating system using command line options?
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