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 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 option has only an effect if
# REMOVE_HOME or REMOVE_ALL_FILES is set.
BACKUP = 0
 
#The 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)”
You may want to see
How to sort contents of a file

The sort command is used to sort the contents of a file. You can sort the data in a text Read more

How to use sed command in Linux

sed, short for "stream editor", allows you to filter and transform text. A stream editor is used to perform basic Read more

How to use crontab in Linux

Cron is the system process that will automatically perform tasks for you according to a set schedule. The schedule is Read more

How to extract archive file in Linux

To extract archive file in Linux, you can use the tar command, used for extracting content from the archive files. "tar" Read more

Leave a Reply

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