Tuesday, 24 March 2015

How to delete user in Linux

To delete user, you can use userdel command. Refer below syntax:
$ userdel [options] <username>

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 user is removed
REMOVE_HOME = 0

# Remove all files on the system owned by the user to be removed
REMOVE_ALL_FILES = 0

# Backup files before removing them. This options has only an effect if
# REMOVE_HOME or REMOVE_ALL_FILES is set.
BACKUP = 0

# target directory for the backup file
BACKUP_TO = "."

# delete a group even there are still users in this group
ONLY_IF_EMPTY = 0

# exclude these filesystem types when searching for files of a user to backup
EXCLUDE_FSTYPES = "(proc|sysfs|usbfs|devpts|tmpfs)"

No comments:

Post a Comment