I am new to Linux & was running some random commands to experiment in terminal (Ubuntu-18.04 LTS) & by mistake I deleted my home directory.

The command I executed is shown in the screenshot of my history below. It was

rm -r /home/dawn

Now all my files are gone, as well as the default folders such as Pictures, Desktop, Screenshots, etc & my desktop screen has turned dark black.

When I tried to open the files icon, it's giving me an error.

Can anyone help me on this?

command history

unable to find the requested file

  • 1
    Have you check your trash folder so you should be able to access it fromthe terminal using the commands in the following link: askubuntu.com/questions/327943/… – Graham Nov 20 '18 at 15:05
  • try this one !! – abu-ahmed al-khatiri Nov 20 '18 at 15:22
  • 1
    follow the steps outlined here askubuntu.com/a/150673/18025 essentially reboot your machine using the same install medium you used to install ubuntu ( memory stick or DVD) then issue outlined commands – Scott Stensland Nov 20 '18 at 15:26
  • 1
    @Graham if OP deleted $HOME how will they be able to access ~/.local/share/Trash from the linked post? Also OP, I am curious why you would rm -r $HOME? I would suggest using a vm if you are going to experiment with dangerous commands like what you did. That being said there is this cgsecurity.org/wiki/TestDisk – j-money Nov 20 '18 at 17:08
  • Understood........ – Krishnendu Dawn Nov 21 '18 at 23:42
  • If you lost some important data try to recover with 'testdisc'.

  • If no important data is lost and you can boot. Go to settings>Details>Users unlock and add another user with Administrative powers, set password and login again or reboot. Login as new user from there you can delete the previous user.

I wonder why you did it.

  • 1
    how will that recover the files? – Graham Nov 20 '18 at 15:13
  • It was an experiment – Krishnendu Dawn Nov 21 '18 at 23:43

If your account was new (without any important/personal files) just re-create your home:

  1. Log out current user from GUI.
  2. Switch to text console by pressing eg. Ctrl+Alt+F1.
  3. Copy fresh user base files and change its ownership:

    sudo cp -r /etc/skel $HOME
    sudo chown `id -u`.`id -g` $HOME


    sudo mkhomedir_helper $USER
  4. Log user again to GUI, your additional dirs will be recreated (Desktop, Pictures etc. - according to /etc/xdg/user-dirs*).

  • @Zanna there is no $HOME/, it was deleted... – madneon Nov 21 '18 at 10:49
  • You are right haha so just that command should do it I think – Zanna Nov 21 '18 at 10:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.