How to delete users on Ubuntu 20.04
On Ubuntu 20.04 you can delete a user using the deluser
command in the terminal or in the graphic user interface. Only root users and those with sudo
privileges can delete a user and their files.
Who can delete a user on Ubuntu?
Only users with root or sudo privileges can delete users in Ubuntu. The same goes for adding new users on Ubuntu 20.04.
- Write perfect emails with optional AI features
- Includes domain, spam filter and email forwarding
- Best of all, it's ad-free
How to delete users on Ubuntu 20.04 in the terminal
One way to remove a user on Ubuntu is with the deluser
command in the terminal.
Deleting users as root
If you are logged in as the root user you can remove any user with the deluser
command. Simply enter the following code in the terminal and replace the placeholder ‘username’ with the user you want to delete:
# deluser username
bashNow you’ve deleted the user, but their account data is still there. To delete this data as well, use the following command. It will delete the home directory and all the files in it.
# deluser --remove-home username
bashDeleting users with sudo
privileges
If you’re not the root user and want to delete a user on Ubuntu 20.04, enter the following code. Replace ‘username’ with the name of the user you want to delete.
$ sudo deluser username
bashTo delete the user’s files, use this command:
$ sudo deluser --remove-home username
bashHow to delete users on Ubuntu 20.04 using the graphic interface
Alternatively, users with sudo
privileges can also delete a user using the graphic user interface. Follow these steps:
- Open the settings.
- Click on User.
- Click on Unlock… You’ll now be asked for your password. Enter it and then confirm.
- Select the user that you want to delete.
- In the bottom right, you’ll see a red button with white letters that says Remove User…. Click on it.
- You’ll be asked to confirm, and then whether you want to delete the user’s home directory. Make your selection, and the user will be deleted.
