How to Delete a User in Linux Ubuntu
Managing users is an essential part of system administration in Linux. In some cases, you may need to delete a user account, such as when an employee leaves a company or when you no longer need a specific user on your system.
In this article, we’ll show you how to delete a user in Linux Ubuntu using both the command line and graphical methods.
Step 1: Open the Terminal
To delete a user from the terminal, first open a terminal window by pressing Ctrl + Alt + T or by searching for “Terminal” in the applications menu.
Step 2: Delete the User
To delete a user, use the userdel command. For example, to delete a user named john, run the following command:
sudo userdel john
Step 3: Remove the User’s Home Directory (Optional)
By default, the userdel command does not remove the user’s home directory. To delete the home directory and all files associated with the user, add the -r flag:
sudo userdel -r john
This will delete both the user account and the home directory located in /home/john.
Step 4: Verify the User Has Been Deleted
To verify that the user has been deleted, you can check the list of users by running:
cat /etc/passwd
Scroll through the list to confirm that the username has been removed.
Step 5: Delete a User via the GUI (Optional)
If you prefer a graphical interface, you can also delete a user through Ubuntu’s Settings application:
- Open Settings.
- Go to the Users section.
- Select the user you want to delete and click the Remove User button.
Conclusion
Deleting a user in Linux Ubuntu is a straightforward process using the userdel command. By following this guide, you can safely remove user accounts, along with their home directories and associated files. Always verify that the user has been deleted from the system after running the command.