How to delete a user in Linux

To delete a user in Linux, you can use userdel command. Refer below syntax:
$ userdel [options]

Example:
$ userdel anil

To remove the user’s home directory pass the -r option to userdel:
$ userdel -r anil

Default values of userdel command are taken from configuration file /etc/login.defs  for RHEL (Red Hat) based distributions. Debian and Ubuntu Linux based system use /etc/deluser.conf file:

 # /etc/deluser.conf: deluser configuration – Debian / Ubuntu Linux only. # Remove home directory and mail spool when the user is removedREMOVE_HOME = 0 # Remove all files on the system owned by the user to be removedREMOVE_ALL_FILES = 0 # Backup files before removing them. This option has only an effect if# REMOVE_HOME or REMOVE_ALL_FILES is set.BACKUP = 0 #The target directory for the backup fileBACKUP_TO = “.” # delete a group even there are still users in this groupONLY_IF_EMPTY = 0 # exclude these filesystem types when searching for files of a user to backupEXCLUDE_FSTYPES = “(proc|sysfs|usbfs|devpts|tmpfs)”

Leave a Reply

Your email address will not be published. Required fields are marked *