2

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

Zanna
  • 70,465
  • 1
    Have you check your trash folder so you should be able to access it fromthe terminal using the commands in the following link: https://askubuntu.com/questions/327943/how-to-open-trash-through-terminal – graham Nov 20 '18 at 15:05
  • 1
    follow the steps outlined here https://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 https://www.cgsecurity.org/wiki/TestDisk – j-money Nov 20 '18 at 17:08
  • Understood........ – Krishnendu Dawn Nov 21 '18 at 23:42
  • worseeee. I did sudo rm -rf /home, and I stopped it midway, but it was too late for that. Now I don't have any wallpaper and most of the apps are broken. And the text on terminal is weird af. But few days ago, I had done a fresh installation on another partition. Thank god for that precious data – Abhay Patil Jan 05 '21 at 20:40

2 Answers2

0
  • 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.

Vijay
  • 8,056
0

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
    

    Or:

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

madneon
  • 1,983
  • 1
  • 13
  • 20