The deluser command is used by system administrators to delete or remove user accounts from Linux systems, including Ubuntu.
Whether you’re a new user or a student learning how to use and manage Linux systems, the easiest place to start might be on Ubuntu Linux OS.
Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.
When you’re ready to learn how to use the deluser commands, follow the guide below:
About deluser command:
The deluser command is used by system administrators to delete or remove user accounts from Linux systems, including Ubuntu. a friendly and alternative command is userdel.
Like using your mouse and keyboard to delete accounts in the GUI. the deluser is the way to do it on the command line.
By default, the deluser command deletes or removes users without deleting or removing their home directories and mail spools.
The syntax is the rule and format of how the deluser command can be used. the syntax’s options can be reordered. but a straight format must be followed.,.
Below is an example syntax of how to use the deluser command.
userdel [options] LOGIN.
The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the command. they are separated by spaces and followed after the command’s options.
Below are some options for the deluser command:
|LOGIN.||Replace LOGIN .. with the name of the account you want to delete. If the account doesn’t already exist, the command will fail and not execute.|
|-f, –force||Use the -f or –force option to force the removal of the user’s files.|
|-r, –remove||Use the -r or –remove option to remove the home directory and mail spool.|
|-R, –root CHROOT_DIR||Use the -R or –root CHROOT_DIR option to specify the directory to chroot into|
|-Z, –selinux-user||Use the -g or –gid GROUP option to remove any SELinux user mapping for the user|
Below are some examples of how to run and use the deluser on Ubuntu Linux.
If you want to delete an account name John, run the commands below.
If you wish to delete or remove John’s account including deleting his home directory, run the commands below.
deluser --remove-home john
If you’re not logged in as a root account, you may have to use the sudo command it it.
sudo deluser --remove-home john
To you want to delete John’s account even while he’s logged in, run the commands below.
sudo deluser --force john
To delete John’s account and back up his home directory, run the commands below.
sudo deluser --backup-to /backup_directory john
The commands above will delete the user account and create an archive of the user’s home directory into the path you specified.
When you run deluser with the –help option, you’ll see the help text below:
Usage: userdel [options] LOGIN Options: -f, --force force removal of files, even if not owned by user -h, --help display this help message and exit -r, --remove remove home directory and mail spool -R, --root CHROOT_DIR directory to chroot into -Z, --selinux-user remove any SELinux user mapping for the user
Hope you like it and please come back soon for more Ubuntu Linux commands!
You may also like the commands below: