How To: Linux Delete / Remove User Account Using userdel

How To: Linux Delete / Remove User Account Using userdel

To delete a user account in Linux using the userdel command, follow these steps:

  1. Open a terminal window.

  2. Use the id command to verify that you are logged in as the root user, or use the sudo command to execute the userdel command with root privileges. For example:

sudo userdel username
Source:w‮ttual.ww‬uri.com
  1. Replace "username" with the name of the user account that you want to delete.

By default, the userdel command will only delete the user's account and not the user's home directory or any files within it. To also delete the user's home directory and all of its contents, use the -r option like this:

sudo userdel -r username

Keep in mind that deleting a user account is a permanent action and cannot be undone. Make sure to back up any important data before deleting a user account.

You can also use the deluser command, which is a wrapper around userdel that provides additional options and compatibility with different Linux distributions. For example:

sudo deluser --remove-home username

This will delete the user account and the user's home directory, just like the userdel -r command.

Created Time:2017-10-29 22:08:34  Author:lautturi