The userdel command is used to delete the existing user account. The userdel command can be used in two ways as mentioned follows:
- userdel <username>: This removes the user entry from the /etc/passwd file, but leaves the user's home directory and mail intact. This way of deleting a user account is not recommended.
- userdel -r <username>: This removes the user and the user's home directory, along with the user's mail box. This will remove the files owned by the user along with the user's account from his home directory. An example of userdel command with option -r is shown in the following screenshot: