PhotoRec is an opensource software to recover media files from Hard Drives, Memory cards, Pendrives etc. It also supports file formats including document formats and archive formats.
PhotoRec can be installed using the following commands
$ yum install testdisk
$ sudo apt-get install testdisk
Recovering files using PhotoRec
Run the following command as root (use sudo in case of Ubuntu) to start PhotoRec.
After starting photorec select the partition from which the files need to be recovered and proceed
Select partition table type
Select partition from the partition table Options and File options can be selected from the same screen.
The options window leads to the following page
Selecting the file option leads to the following page
After selecting the Options and File types select the filesystem type below
Select whether free space on the disk or Whole disk need to be checked for recoverable files
Select the path where the recovered files need to be stored
Finally after restoring the files on the path use quit to exit PhotoRec