I had accidentally deleted a few files from an Ubuntu Desktop. Now I need to recover only the perl files which had been sitting in /home/user directory. How can this be done? I am able to boot using a live Ubuntu USB. Please explain.
|
testdisk is a lot more efficient than photorec. The problem with testdisk is that it doesn't always recover all deleted files. If you accidentally reformat a partition, testdisk can recover thousands of files without missing a single file, but if you deleted a file by sending it to the Trash and then emptying the Trash, testdisk can't always recover it. So use testdisk first, and if you recovered all of the deleted files with testdisk, then you're done. If you recovered most of the deleted files with testdisk, you can decide whether you're done or not. If you're not done after running testdisk, you can try recovering the deleted files using photorec. PhotoRec can selectively recover files based on their filetype(s), but photorec/testdisk can't selectively scan an individual directory for lost files unless you had mounted a whole hard drive partition as this directory. In some cases, the filename is stored in the file itself. PhotoRec tries to recover the filename in this case, but most of the time PhotoRec can't recover the filenames. Recover files based on filetype using PhotoRec
Photorec will show how many files it has recovered. Source: revised from How To Recover Deleted Files in Linux Using Photorec |
|||||
|
photorecis probably not a viable solution, unless you have a separate home partition; running it on the root partition will have the effect of recovering thousands of files without any metadata (i.e. with a filname generated byphotorecon-the-fly, not useful to understand which files are the files you're looking for; at the very least you'll need to usegrep -l '#!/usr/bin/perl'or variations and hope that not too many perl scripts exist / have existed in your system). Usingtestdiskyou should be able to recover just the deleted folder / files by browsing the filesystem. – kos Sep 20 '15 at 11:55testdisk; you should be able to adapt it and use it to recover the files; if no avail, you should try karel's solution, but you'll need to go through all the files somehow – kos Sep 20 '15 at 12:00