How to Delete a User in Ubuntu

  • Post category:Ubuntu

Managing user accounts is a vital part of system administration in Ubuntu. Whether you’re cleaning up accounts that are no longer needed or adjusting access permissions, knowing how to delete a user efficiently is essential. In this guide, we’ll explore both command-line and graphical methods to delete a user in Ubuntu.

Method 1: Using the Command Line

Step 1: Open Terminal

Start by pressing Ctrl + Alt + T to open the terminal on your Ubuntu system.

Step 2: Delete the User

To delete a user account without removing their home directory, use the following command:

sudo deluser username

Be sure to replace username with the actual username you wish to delete.

Step 3: Delete the User and Their Home Directory

If you also want to remove the user’s home directory along with their account, run this command instead:

sudo deluser --remove-home username

Step 4: Verify User Deletion

To ensure the user has been successfully deleted, you can check the /etc/passwd file with this command:

cat /etc/passwd | grep username

If there’s no output, the user has been successfully removed from the system.

Method 2: Using the Graphical Interface

Step 1: Open Settings

Click on the system menu located in the top right corner and select Settings.

Step 2: Navigate to Users

In the Settings window, click on the Users section to manage user accounts.

Step 3: Unlock Settings

To make changes, click on the Unlock button in the top right corner. Enter your password when prompted to proceed.

Step 4: Select User to Delete

Click on the user account you want to remove under the Other Users section.

Step 5: Remove User

Press the Remove User… button. You’ll be asked to confirm whether you want to delete the user’s home folder as well.

Step 6: Confirm Deletion

Decide whether to keep or delete the user’s files, and then confirm your choice to finalize the deletion.

Conclusion

Deleting a user in Ubuntu is a straightforward task, whether you prefer the command line or a graphical interface. By following the steps outlined in this guide, you can effectively manage user accounts on your system. For more tips on system administration, be sure to check out our other articles on CodeAllow.