Ubuntu: How to Remove a User Account

Contributor Icon Contributed by Rob Rogers  
Tag Icon Tagged: Linux  

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//

 

14 Comments -


  1. CS said on February 18, 2009

    sudo userdel -r [username]

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

  2. Stefan said on April 24, 2009

    Thanks – it worked a treat.

  3. blake said on May 27, 2009

    thanks. very helpful

  4. Mark said on June 28, 2009

    I believe this way is better:

    sudo userdel -r NameOfUserToDelete

  5. Anonymous said on October 7, 2009

    ubuntu is very helpful linux operating system

  6. Anonymous said on February 24, 2010

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

  7. Windows User said on February 25, 2010

    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.

  8. Nick said on April 17, 2010

    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.

  9. jetp said on January 11, 2011

    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.)

  10. luke said on March 23, 2011

    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//

  11. luke said on March 23, 2011

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

  12. Kevin Li said on July 22, 2011

    I agree.

  13. Sander said on November 24, 2011

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

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

  14. zaid said on December 12, 2011

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

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -