Linux and Unix userdel command

Quick links

About userdel
Syntax
Examples
Related commands
Linux and Unix main page

About userdel

Enables a super user to remove a users account.

Syntax

userdel [-r] login

-rFiles in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.

EXIT VALUES

0 - success
1 - can't update password file
2 - bad command syntax
6 - specified user doesn't exist
8 - user currently logged in
10 - can't update group file
12 - can't remove home directory

Examples

Tip For these commands to work you must have super user rights or be logged in as root.

Warning In the below example the userdel command would remove the newperson account and also the newpersons home directory directory, in this case (/home/newperson).

userdel -r newperson

Related commands

useradd
usermod