If we have deleted files we didn't want to delete and we want to recover them, we have a tool called 'foremost' for Ubuntu very easy to use in the command-line
First we need to install foremost in Ubuntu:
sudo apt-get install foremost
Next we need to know the name of the partition or the hard disk to recover, we can use 'df -h' to check wich partition we want to recover:
>>df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb3 74G 41G 29G 59% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
udev 2,4G 4,0K 2,4G 1% /dev
tmpfs 497M 1,7M 495M 1% /run
none 5,0M 0 5,0M 0% /run/lock
none 2,5G 84M 2,4G 4% /run/shm
none 100M 68K 100M 1% /run/user
/dev/sda5 1,6T 285G 1,2T 20% /media/USERNAME/EXTERNAL-HDD
/dev/sdc1 7,5G 4,8G 2,8G 64% /media/USERNAME/USB
For this example I'm using USB, the partition of the USB is "/dev/sdc1" we execute the command like this:
sudo foremost -i /dev/sdc1 -o
Done ! We have to wait until the process ends and then check the files. The program recover the files ordered in folders by file type.