Ubuntu: How to Remove a User Account

From time to time, it becomes necessary to remove a user account from your computer. Removing a user account from your Ubuntu system is a simple task that requires two separate terminal commands.


1. Open a terminal window.

2. First, you’ll need to delete the user account. Input the following command and hit Enter (change to the name of the user account that is to be removed):sudo userdel
3. Now you’ll want to delete the Home directory for the deleted user account. Input the following command and hit Enter (change to the name of the user account that is to be removed):sudo rm -r /home//

 

About Rob Rogers

Once a prolific author here on Tech-Recipes, Rob has moved on to greener pastures.
View more articles by Rob Rogers

The Conversation

Follow the reactions below and share your own thoughts.

  • CS

    sudo userdel -r [username]

    removes the user’s home directory as well as deleting the user.

  • http://www.faithinme.co.uk Stefan

    Thanks – it worked a treat.

  • blake

    thanks. very helpful

  • Mark

    I believe this way is better:

    sudo userdel -r NameOfUserToDelete

  • Anonymous

    ubuntu is very helpful linux operating system

  • Anonymous

    deluser is more helpful -> it deleted the user and its user folder.

  • Windows User

    Nice, I’ve just deleted my home folder with all the data from all the users.

    I am trying to learn linux and that is why I hate linux.

    “following command and hit Enter (change to the name of the user account that is to be removed):
    sudo rm -r /home//”

    change what with my user name? I thought that using “//” will ask me for my user folder or something like that.

    It was nice to state that this tutorial is not for an absolute beginner.
    I am searching for another tutorial to recover my files but there are a ton of unusefull discussions about how not to be dumb and delete by mistake or how to backup but no one tries to explain how to do it.

    • Nick

      I too am a heavy windows user, and I would never go to a command prompt and type del C:documents and setting thinking it would prompt me for the user. Why would you think it would in Linux.

      This is why I am learning Linux… To get into a community that thinks. Most window users think computers have little fairies doing the actions the user wants and not what they type.

  • jetp

    windows user – i’m sorry to hear about the problem you had. i would say the instructions here were unclear. additionally, this could be done through a gui, which is generally safer.
    in generally, the command prompt in linux can be quite dangerous. very powerful, can be extremely efficient, but these ability come at that the cost of commands that can delete a lot of data without a confirmation. i remember once seeing a list of commands that you should never type at the terminal because they will actually delete the entire filesystem. some didn’t even look dangerous! but that is where some basic experience and also the general rule that if you don’t understand a command and you can’t verify what it will do, don’t run it.
    again, sorry for the inconvenience, i hope it hasn’t turned you off from linux indefinitely (and hopefully for novice users, the GUI interfaces that make many operations less dangerous or build in confirmation dialogs will continue to improve.)

  • luke

    I hope the author correct his/her sample commands by HTML escaping the ” so string “” shows correctly on a web page. Otherwise this is really confusing and it already done some harms to people.

    sudo userdel
    sudo rm -r /home//

    • luke

      ironic.. i got tripped up by the auto closing of html tags :)

  • http://www.facebook.com/people/Kevin-Li/100000173225758 Kevin Li

    I agree.

  • Sander

    If you give an example like following, maybe people won’t accidentally delete their home folder

    sudo userdel [username]
    sudo rm -r /home/[username]/

  • zaid

    i delete the user but i need to back user can i????? its very imbortant

  • gonzalo.cao

    tks dude,

    very usefull!

  • shanmuganathan

    Thanks it works fine

  • Jarod Cook

    If you’re ever unsure of what a command will do, put –help by the base command. Like rm –help or userdel –help.

  • sd

    sudo userdel -r namedelete

  • Vaccix

    Noobish

  • Bouke

    `deluser` can also remove the user’s files and cleans up empty groups.