Linux Basic Commands
8. userdel
userdel Command in Linux
The userdel command is used to delete a user account from the system.
β οΈ Requires root privileges, so use it with sudo.
πΉ Basic Syntax:
userdel [username]
πΉ Example:
userdel ashwin
π This command deletes the user account named ashwin.
πΈ Note: By default, this does not delete the user's home directory.
πΉ Delete user and their home directory:
userdel -r ashwin
π This removes:
-
The user account
ashwin -
Their home folder:
/home/ashwin -
Their mail spool and personal files
πΉ How to confirm user is deleted:
cat /etc/passwd | grep ashwin
π If no output, the user is deleted.
πΉ Warning:
Donβt delete users while they are logged in.
It can cause system issues. First, check:
whoTry with Linux Practice