This tutorial explains Linux “userdel” command, options and its usage with examples.
Description :
The userdel command modifies the system account files, deleting all entries that refer to login. The named user must exist.
Usage :
userdel [options] username
Options :
-r
Files 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.
-h, –help
Display a help message, and exit.
-f, –force
This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to remove the user’s home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user.
Exit Values
The userdel command exits with the following values:
0 success 1 can't update password file 2 invalid 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 :
1. To remove the user abc account from the local system / server / workstation, enter:
# userdel vivek
2. To remove the user’s home directory pass the -r option to userdel, enter:
# userdel -r abc
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Apply for Programming Internship
- Buy Information Technology Books
- Buy Linux Books
- Practice Programming MCQs
- Apply for Linux Internship