userdel command in Linux with Examples

userdel command in Linux system is used to delete a user account and related files. This command basically modifies the system account files, deleting all the entries which refer to the username LOGIN. It is a low-level utility for removing the users.


userdel [options] LOGIN


  • userdel -f: This option forces the removal of the specified user account. It doesn’t matter that the user is still logged in. It also forces the userdel to remove the user’s home directory and mail spool, even if another user is using the same home directory or even if the mail spool is not owned by the specified user.


    sudo userdel -f neuser

  • userdel -r: Whenever we are deleting a user using this option then the files in the user’s home directory will be removed along with the home directory itself and the user’s mail spool. All the files located in other file systems will have to be searched for and deleted manually.


    sudo userdel -r newuser2

  • userdel -h : This option display help message and exit.


    userdel -h

  • userdel -R: This option apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.


    sudo userdel -R newuser2

  • userdel -Z : This option remove any SELinux(Security-Enhanced Linux) user mapping for the user’s login.


    sudo userdel -Z newuser2

  • userdel command with help option: The userdel command throws an error if no options, filename or arguments are passed. So, when we use the -h option, it gives the general syntax along with the various options that can be used with the userdel command.


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.