{"id":13279,"date":"2019-04-01T11:11:06","date_gmt":"2019-04-01T11:11:06","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13279"},"modified":"2019-04-01T11:11:06","modified_gmt":"2019-04-01T11:11:06","slug":"photorec-recover-deleted-or-lost-files-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/photorec-recover-deleted-or-lost-files-in-linux\/","title":{"rendered":"PhotoRec \u2013 Recover Deleted or Lost Files in Linux"},"content":{"rendered":"<p>When you delete a file accidentally or intentionally on your system using \u2018<strong>shift + delete<\/strong>\u2018 or delete option or empty Trash, the file content is not destroyed from the hard disk (or any storage media).<\/p>\n<p>It is simply removed from the the directory structure and you cannot see the file in the directory where you deleted it, but it still remains somewhere in your hard drive.<\/p>\n<p>If you have the appropriate tools and knowledge, you can\u00a0<a href=\"https:\/\/www.tecmint.com\/recover-deleted-file-in-linux\/\" target=\"_blank\" rel=\"noopener\">recover lost files from your computer<\/a>. However, as you store more files on your hard disk, the deleted files are overwritten, you may only recover recently deleted files.<\/p>\n<p>In this tutorial, we will explain how to recover lost or deleted files on a hard disk in Linux using\u00a0<strong>Testdisk<\/strong>, is a remarkable recovery tool ships in with a free tool called\u00a0<strong>PhotoRec<\/strong>.<\/p>\n<p><strong>PhotoRec<\/strong>\u00a0is used to recover lost files from storage media such as hard drives, digital camera and cdrom.<\/p>\n<h3>Install Testdisk (PhotoRec) in Linux Systems<\/h3>\n<p>To install\u00a0<strong>Testdisk<\/strong>\u00a0by running the relevant command below for your distribution:<\/p>\n<pre>------- <strong>On Debian\/Ubuntu\/Linux Mint<\/strong> ------- \r\n$ sudo apt-get install testdisk\r\n\r\n------- <strong>On CentOS\/RHEL\/Fedora<\/strong> ------- \r\n$ sudo yum install testdisk\r\n\r\n------- <strong>On Fedora 22+<\/strong> ------- \r\n$ sudo dnf install testdisk   \r\n\r\n------- <strong>On Arch Linux<\/strong> ------- \r\n$ pacman -S testdisk             \r\n\r\n------- <strong>On Gentoo<\/strong> ------- \r\n$ emerge testdisk  \r\n<\/pre>\n<p>In case it is not available on your Linux distribution\u2019s repositories, download it from\u00a0<a href=\"https:\/\/www.cgsecurity.org\/wiki\/TestDisk_Download\" target=\"_blank\" rel=\"nofollow noopener\">here<\/a>\u00a0and run it on a Live CD.<\/p>\n<p>It can also be found in rescue CD such as\u00a0<strong>Gparted LiveCD<\/strong>,\u00a0<strong>Parted Magic<\/strong>,\u00a0<strong>Ubuntu Boot CD<\/strong>,\u00a0<strong>Ubuntu-Rescue-Remix<\/strong>\u00a0and many more.<\/p>\n<p>Once the installation is complete, start\u00a0<strong>PhotoRec<\/strong>\u00a0in a text window as follows with root privileges and specify the partition from which the files where deleted:<\/p>\n<pre>$ sudo photorec \/dev\/sda3\r\n<\/pre>\n<p>You\u2019ll see the interface below:<\/p>\n<div id=\"attachment_24106\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/PhotoRec-Data-Recovery-Tool.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24106\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/PhotoRec-Data-Recovery-Tool.png\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/PhotoRec-Data-Recovery-Tool.png 771w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/PhotoRec-Data-Recovery-Tool-768x494.png 768w\" alt=\"PhotoRec Data Recovery Tool for Linux\" width=\"771\" height=\"496\" aria-describedby=\"caption-attachment-24106\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24106\" class=\"wp-caption-text\">PhotoRec Data Recovery Tool for Linux<\/p>\n<\/div>\n<p>Use the\u00a0<code>right<\/code>\u00a0and\u00a0<code>left<\/code>\u00a0arrow keys to select a menu item, and press\u00a0<strong>Enter<\/strong>. To continue with the recovery operation, select\u00a0<code>[Proceed]<\/code>\u00a0and hit\u00a0<strong>Enter<\/strong>.<\/p>\n<p>You will be at the following interface:<\/p>\n<div id=\"attachment_24107\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Partition-to-Proceed-File-Recovery.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24107\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Partition-to-Proceed-File-Recovery.png\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Partition-to-Proceed-File-Recovery.png 778w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Partition-to-Proceed-File-Recovery-768x490.png 768w\" alt=\"Select Partition to Proceed File Recovery\" width=\"778\" height=\"496\" aria-describedby=\"caption-attachment-24107\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24107\" class=\"wp-caption-text\">Select Partition to Proceed File Recovery<\/p>\n<\/div>\n<p>Select\u00a0<code>[Options]<\/code>\u00a0to view available recovery operation options as in the interface below:<\/p>\n<div id=\"attachment_24108\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Options.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24108\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Options.png\" alt=\"Linux File Recovery Options\" width=\"740\" height=\"496\" aria-describedby=\"caption-attachment-24108\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24108\" class=\"wp-caption-text\">Linux File Recovery Options<\/p>\n<\/div>\n<p>Press\u00a0<code>Q<\/code>\u00a0to move back, at the interface below, you can specify the file extensions you want to search and recover. Therefore, select\u00a0<code>[File Opt]<\/code>\u00a0and press\u00a0<strong>Enter<\/strong>.<\/p>\n<p>Press\u00a0<code>s<\/code>\u00a0to disable\/enable all file extensions, and in case you have disabled all file extensions, only choose types of files you want to recover by selecting them using\u00a0<code>right<\/code>\u00a0arrow keys (or\u00a0<code>left<\/code>\u00a0arrow key to deselect).<\/p>\n<p>For instance, I want to recover all\u00a0<code>.mov<\/code>\u00a0files that I lost on my system.<\/p>\n<div id=\"attachment_24109\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Specify-Recovery-File-Type.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24109\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Specify-Recovery-File-Type.png\" alt=\"Specify Recovery File Type\" width=\"749\" height=\"496\" aria-describedby=\"caption-attachment-24109\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24109\" class=\"wp-caption-text\">Specify Recovery File Type<\/p>\n<\/div>\n<p>Then press\u00a0<code>b<\/code>\u00a0to save the setting, you should see the message below after pressing it. Move back by hitting\u00a0<strong>Enter<\/strong>\u00a0(or simply press\u00a0<code>Q<\/code>\u00a0button), then press\u00a0<code>Q<\/code>\u00a0again to go back to the main menu.<\/p>\n<div id=\"attachment_24110\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Save-File-Recovery-Settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24110\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Save-File-Recovery-Settings.png\" alt=\"Save File Recovery Settings\" width=\"759\" height=\"394\" aria-describedby=\"caption-attachment-24110\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24110\" class=\"wp-caption-text\">Save File Recovery Settings<\/p>\n<\/div>\n<p>Now select\u00a0<code>[Search]<\/code>\u00a0to start the recovery process. In the interface below, choose the filesystem type where the file(s) were stored and hit\u00a0<strong>Enter<\/strong>.<\/p>\n<div id=\"attachment_24111\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Recover-Files.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24111\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Recover-Files.png\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Recover-Files.png 783w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Recover-Files-768x335.png 768w\" alt=\"Select Filesystem to Recover Deleted Files\" width=\"783\" height=\"342\" aria-describedby=\"caption-attachment-24111\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24111\" class=\"wp-caption-text\">Select Filesystem to Recover Deleted Files<\/p>\n<\/div>\n<p>Next, choose if only free space or the whole partition needs to be analyzed as below. Note that choosing whole partition will make the operation slower and longer. Once you have selected the appropriate option, press\u00a0<strong>Enter<\/strong>to proceed.<\/p>\n<div id=\"attachment_24112\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Analyze.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24112\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Filesystem-to-Analyze.png\" alt=\"Choose Filesystem to Analyze\" width=\"756\" height=\"314\" aria-describedby=\"caption-attachment-24112\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24112\" class=\"wp-caption-text\">Choose Filesystem to Analyze<\/p>\n<\/div>\n<p>Closely select a directory where recovered files will be stored, if the destination is correct, press\u00a0<code>C<\/code>\u00a0button to continue. Choose a directory on a different partition to avoid deleted files being overwritten when more data is stored on the partition.<\/p>\n<p>To move back until the root partition, use the\u00a0<code>left<\/code>\u00a0arrow key.<\/p>\n<div id=\"attachment_24113\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Directory-to-Save-Recovered-Files.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24113\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Directory-to-Save-Recovered-Files.png\" sizes=\"auto, (max-width: 774px) 100vw, 774px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Directory-to-Save-Recovered-Files.png 774w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Select-Directory-to-Save-Recovered-Files-768x586.png 768w\" alt=\"Select Directory to Save Recovered Files\" width=\"774\" height=\"591\" aria-describedby=\"caption-attachment-24113\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24113\" class=\"wp-caption-text\">Select Directory to Save Recovered Files<\/p>\n<\/div>\n<p>The screenshot below shows deleted files of the specified type being recovered. You can stop the operation by pressing\u00a0<strong>Enter<\/strong>.<\/p>\n<p><strong>Note<\/strong>: Your system may become slow, and possibly freeze at certain moments, so you need to be patient until when the process is complete.<\/p>\n<div id=\"attachment_24114\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Recover-Deleted-Files-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24114\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Recover-Deleted-Files-in-Linux.png\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Recover-Deleted-Files-in-Linux.png 769w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Recover-Deleted-Files-in-Linux-768x497.png 768w\" alt=\"Recovering Deleted Files in Linux\" width=\"769\" height=\"498\" aria-describedby=\"caption-attachment-24114\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24114\" class=\"wp-caption-text\">Recovering Deleted Files in Linux<\/p>\n<\/div>\n<p>At the end of the operation,\u00a0<strong>Photorec<\/strong>\u00a0will show you the number and the location of files recovered.<\/p>\n<div id=\"attachment_24115\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Summary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24115\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Summary.png\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Summary.png 796w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Linux-File-Recovery-Summary-768x542.png 768w\" alt=\"Linux File Recovery Summary\" width=\"796\" height=\"562\" aria-describedby=\"caption-attachment-24115\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24115\" class=\"wp-caption-text\">Linux File Recovery Summary<\/p>\n<\/div>\n<p>The recovered files will be stored with root privileges by default, therefore open your file manager with elevated privileges to access the files.<\/p>\n<p>Use the command below (specify your file manager):<\/p>\n<pre>$ gksudo nemo\r\nor\r\n$ gksudo nautilus \r\n<\/pre>\n<p>For more information, visit PhotoRec homepage:\u00a0<a href=\"https:\/\/www.cgsecurity.org\/wiki\/PhotoRec\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/www.cgsecurity.org\/wiki\/PhotoRec<\/a>.<\/p>\n<p>That\u2019s all! In this tutorial, we explained the necessary steps to recover deleted or lost files from hard disk using PhotoRec. This is so far the most reliable and effective recovery tool I have ever used, if you know any other similar tool, do share with us in the comments.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/photorec-recover-deleted-lost-files-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you delete a file accidentally or intentionally on your system using \u2018shift + delete\u2018 or delete option or empty Trash, the file content is not destroyed from the hard disk (or any storage media). It is simply removed from the the directory structure and you cannot see the file in the directory where you &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/photorec-recover-deleted-or-lost-files-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PhotoRec \u2013 Recover Deleted or Lost Files in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13279","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13279"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13279\/revisions"}],"predecessor-version":[{"id":13280,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13279\/revisions\/13280"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}