Made a huge mistake and deleted my /home/user folder (Ubuntu 14.04 LTS)

I was following this question here: Nautilus Thumbnails Size Fix

I screwed something up and I don’t know how to fix it.
I installed dconf-editor and changed the thumbnail size in nautilus. after that was done, I entered (or at least I thought I did):

sudo rm -r ~/.cache/thumbnails/ 

Now it looks like my user settings are gone.

My bookmarks in chromium are gone, the downloads directory is empty, and I know there were some files in there with some TV show episodes in them.

I looked in the system log and discovered that I typo’d the path as /home/zombie /.c.cache/thumbnails/ From the system auth.log

 May 28 15:55:54 Zombie-Dell sudo:   zombie : TTY=pts/4 ; PWD=/home/zombie ; USER=root ; COMMAND=/bin/rm -r /home/zombie /.c.cache/thumbnails/

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Stop using that Ubuntu installation

First of all immediately stop using that Ubuntu installation. Now!

You should boot straight to a live DVD/USB. If you don’t have one, do not download it from that system and go get it somewhere else. However, if you have a dual boot, you might also use Windows to download the ISO.

Try to access the deleted files

When you are using the live DVD, check the partitions with:

sudo parted -l

You need to find the right one that contains your home directory. For example, my computer shows the following for drive /dev/sda:

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  256MB  255MB  primary   ext2         boot
 2      257MB   250GB  250GB  extended
 5      257MB   250GB  250GB  logical

This is not the best example because I am using full disk encryption, but assuming I wanted to restore files from /boot I would target /dev/sda1 (basically look at the number).

At this point, connect an external hard drive where you want to recover the files.

Now you need to install a program called Testdisk:

sudo apt install testdisk

Then run it on your drive:

sudo testdisk /dev/sda

It will display an interactive procedure that you need to follow through the textual interface. Basically you will arrive at a list of partitions and you need to select the right one with the arrow keys.

Then you will need to press P to show the files and navigate in the directory tree. Once you have determined that hopefully your home directory contains the stuff (shown in red since it has been deleted), go one level up so that you highlight your username inside /home and press C to activate the Copy function.

Testdisk will ask you where you want to save the files. Navigate to a directory in your external hard drive and confirm. Wait patiently while it restores your data in the external drive.

Bottom line

Ubuntu has a backup program installed by default. You should use it routinely, before something like this happens again.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply