In this post, I would show the difference between the
deluser commands in Linux Operating Systems.
- Ubuntu System
3. What is the difference between the
deluser in Linux?
3.1 What is
userdel command can be used to delete user accounts. This command can only be used by root users.
userdel can delete user accounts and related files. If no parameters are added, only the user account will be deleted, and the related files will not be deleted.
The grammer of the this command is:
userdel [-r] [user_account]
The -r option means to delete the user’s home directory while deleting the user.
We know that user information is stored in below files:
- Basic user information: stored in the /etc/passwd file
- User password information: stored in the /etc/shadow file
- Basic user group information: stored in the /etc/group file
- User group information: stored in the /etc/gshadow file
- User personal files: The home directory is located at
/home/usernameby default, and the mailbox is located at /var/spool/mail/username
In fact, the function of the userdel command is to delete the data information related to the specified user from the above files.
3.2 What is
deluser command can be used to delete users. To delete a user from a group (ie exit the user group), everyone recommends
usermod, but deluser is the more preferable manner.
deluser has richer options and more powerful functions than userdel.
Delete a normal user:
[[email protected] ~]# deluser mike
There are more options to specify when deleting a user:
--remove-homedelete the user’s home directory and mailbox
--remove-all-filesdelete all files owned by the user
--backupBack up files before deleting.
--backup-to<DIR>The destination directory of the backup. The default is the current directory.
--systemDelete only when the user is a system user.
Delete user from group:
[[email protected] ~]# deluser mike admingroup
Delete all files of user:
[[email protected] ~]# deluser --remove-all-files mike
3.3 The difference
userdelis a binary file in the system, but
deluseris a script file in the system
deluseris more low-level then
userdel, it provides us more complicated and comprehensive options to delete users and groups
userdelis more high-level command in the system, it provide us with a more intuitive and feasible command to delete users.
In this post, I tried to explain the difference between
deluser in Linux system.