Mistakenly deleting a file can be sometimes a nightmare. I have done this before. I think every system admin have deleted accidentally a file from Linux. To recover deleted files in Linux there are different tools. Best way to recover a file is running live Linux on the disk where file is deleted because using same disk to recovery can harm our deleted files.
Recover Files With Foremost
First we will install foremost. In this scenario we run recovery software no in live Linux.
$ sudo apt install foremost
$ rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
$ yum install foremost
We will us simple and single command to recover files
$ foremost -t jpg -i /dev/sda1 -o /media/ismail/usb
- -t jpg options provides file types those will be recovered
- -i /dev/vda1 is the device where the deleted files resides
- -o /media/ismail/usb is the path deleted files saved