If you’re an Ubuntu user, you may need to delete a user account for various reasons. Maybe the user is no longer needed, or you want to free up some space on your system. Whatever your reason may be, deleting a user account is a straightforward process that can be done using various methods.
In this article, we’ll show you how to delete a user in Ubuntu using the command line and the graphical user interface (GUI).
Understanding User Accounts in Ubuntu
Before we dive into the steps to delete a user in Ubuntu, let’s first understand what user accounts are and how they work.
A user account is a collection of information that identifies a user to the system. It includes a username, password, and a unique user ID (UID) that the system uses to identify the user. Each user account is associated with a home directory, which is the default location for storing the user’s files and settings.
Ubuntu supports two types of user accounts: system accounts and regular user accounts. System accounts are used by the operating system to run system services and daemons, while regular user accounts are used by human users to log in to the system and perform tasks.
Now that we have a basic understanding of user accounts let’s move on to the steps to delete a user in Ubuntu.
Deleting a User in Ubuntu Using the Command Line
The command line is a powerful tool that allows you to perform various tasks, including deleting a user in Ubuntu. Here are the steps to follow:
Step 1: Open the Terminal
To open the terminal, press CTRL
+ ALT
+ T
on your keyboard, or click on the terminal icon in the system menu.
Step 2: Log in as Root or Sudo User
To delete a user account, you need to have root or sudo privileges. If you’re not logged in as root, you can switch to the root user by typing the following command in the terminal:
sudo su
You’ll be prompted to enter your password. After entering the password, you’ll be logged in as the root user.
Step 3: Delete the User Account
To delete a user account, use the userdel
command followed by the username of the account you want to delete. For example, to delete the user account named john
, type the following command:
userdel john
This command will delete the user account and its associated home directory.
Step 4: Remove the User’s Files
By default, the userdel
command only deletes the user account and its associated home directory. If you want to delete the user’s files as well, use the -r
option. For example, to delete the user account named john
and all its files, type the following command:
userdel -r john
This command will delete the user account, its associated home directory, and all the files stored in it.
Deleting a User in Ubuntu Using the GUI
If you’re not comfortable using the command line, you can also delete a user in Ubuntu using the graphical user interface (GUI). Here are the steps to follow:
Step 1: Open the System Settings
Click on the system menu in the top-right corner of the screen and select “Settings.”
Step 2: Open the User Accounts Settings
In the “Settings” window, click on the “User Accounts” icon. This will open the “User Accounts” settings.
Step 3: Select the User Account to Delete
In the “User Accounts” settings, select the user account you want to delete. You can do this by clicking on the account’s name.
Step 4: Click on the “Minus” Button
After selecting the user account, click on the “Minus” button at the bottom of the window. This will open a confirmation dialog.
Step 5: Confirm the Deletion
In the confirmation dialog, click on the “Delete” button to confirm the deletion. The user account and its associated home directory will be deleted.
Conclusion
Deleting a user in Ubuntu is a simple process that can be done using the command line or the graphical user interface. By following the steps outlined in this article, you can delete user accounts and free up space on your system. Remember to exercise caution when deleting user accounts, as this can have unintended consequences.