To delete a user account in Linux, you can use the userdel command. Here’s how to do it:
Basic Command
To delete a user account without removing their home directory:
sudo userdel username
Delete User and Home Directory
To delete the user account and also remove their home directory and mail spool, use the -r option:
sudo userdel -r username
Example
If you want to delete a user named alice and their home directory, you would run:
sudo userdel -r alice
Important Note
Make sure you have administrative privileges to execute these commands, and be cautious when deleting user accounts, especially in production environments, as this action is irreversible.
