{"id":114610,"date":"2020-11-18T11:00:51","date_gmt":"2020-11-18T08:00:51","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-recover-deleted-files-on-linux-with-testdisk\/"},"modified":"2020-11-18T11:00:51","modified_gmt":"2020-11-18T08:00:51","slug":"how-to-recover-deleted-files-on-linux-with-testdisk","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/","title":{"rendered":"#How to Recover Deleted Files on Linux with testdisk"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2e140e00cf2\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2e140e00cf2\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/#rm_Short_for_Remorse\" >rm: Short for Remorse?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/#Installing_testdisk\" >Installing testdisk<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/#Using_testdisk\" >Using testdisk<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/#Working_with_Restored_Files\" >Working with Restored Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-recover-deleted-files-on-linux-with-testdisk\/#testdisk_Code_for_Relief\" >testdisk: Code for Relief<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Recover Deleted Files on Linux with testdisk&#8221;<\/strong><\/p>\n<div>\n<figure id=\"attachment_442612\" style=\"width: 650px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-442612 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2019\/09\/xstock-lede-linux-see-attribution.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.rjm91kC_Jl.png\" alt=\"An illustration of a terminal window on a Linux computer.\" width=\"650\" height=\"300\" data-credittext=\"Fatmawati Achmad Zaenuri\/Shutterstock\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">Fatmawati Achmad Zaenuri\/Shutterstock<\/a><\/span><\/figcaption><\/figure>\n<p>Have you ever deleted a file and instantly regretted it? You need it back, and fast! But what if the file is so new, it hasn\u2019t yet been backed up? Fortunately, there\u2019s something you can do about it.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"rm_Short_for_Remorse\"><\/span>rm: Short for Remorse?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>It\u2019s all too easy to use the <code>rm<\/code> command\u00a0and find yourself staring at a terminal window with a deepening sense of regret. One small mistake with wildcards, and you can wipe out a lot more than you intended to.<\/p>\n<p>The default Linux file system,\u00a0<code>ext4<\/code> uses inodes to hold data about each file\u00a0and an inode table to keep track of the inodes. The inode contains metadata about the file, such as its name, who owns it, what the permissions are, and so on.<\/p>\n<p>It also contains entry points to hard links that point to the file. Each file has at least one hard link. Each time you create a new hard link, the hard link count increases by one. Each time you remove a hard link, the hard link count in the inode is reduced by one.<\/p>\n<p>When you delete a file the inode has marked as unused (and ready for reuse), the last hard link is removed. When this h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens, the file won\u2019t appear in directory listings, and it cannot be used or accessed.<\/p>\n<p>However, the data that made up the contents of the file is still present on the hard drive. If you could patch the inode so it contained the correct information, though, the file would be restored. Of course, this would only work if the data that makes up the file on the hard drive remains intact and isn\u2019t overwritten.<\/p>\n<p>Alternatively, you could create a new inode, copy the surviving data from the old inode, and then replace the missing bits.<\/p>\n<p>Those are nontrivial activities. Usually, when you delete a file by mistake, it\u2019s at the worst possible moment. It\u2019s always when you need that file, and you need it now. You don\u2019t have time to get down and dirty with sector editors and other utilities. Plus, if it\u2019s a file you just created, it likely hasn\u2019t yet been backed up, so those won\u2019t help you, either.<\/p>\n<p>This where <code>testdisk<\/code> comes in. It\u2019s easy to use and doesn\u2019t require detailed, low-level knowledge of the filesystem. Let\u2019s take a look at how to use it!<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>Everything You Ever Wanted to Know About inodes on Linux<\/em><\/strong><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_testdisk\"><\/span>Installing testdisk<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To install <code>testdisk<\/code> on Ubuntu, use this command:<\/p>\n<pre>sudo apt-get install testdisk<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700342 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x1-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.6eBA4ZN46x.png\" alt=\"sudo apt-get install testdisk in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>On Fedora, you need to type:<\/p>\n<pre>sudo dnf install testdisk<\/pre>\n<p><img decoding=\"async\" class=\"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prQlVeVxAxhYUfBUFUNE3+jWAbzzNKB1H8y60VH675iyA726HHMD356fbb98BTmd1wnFpj16nzsvtlnU9t7w43ATAseIyzlh\/RLl4vS3zh2F9UOr21fhaMvL1nHJdQcbtamjOY86vP8p+KevU\/ZhXL\/2lj8wHcoE7w9TQpoZtF4KuKRfw492t\/UejANCxHgBCjRk5P80CrmNS2NZRf7IEvppw+OchAL9U3yw87jXUKfNyu2XdrxtPNLX+BgBTc3N3Cyw1bPg9HF5l+KZY6g5Gg\/7xfD2n1l9SqeN2NTTnMefXHwVlneyHuV76Sx+ZD2QDvrleamj\/e8N43HCVIqnuviay\/fX1fxhqaKXhFe2PeXHpnpkZTbl\/cVY6nX+o598sNfz\/aUioITWkhtSQGhJqSAg1JNSQENGQ\/xJFeBoSQg3JEtHwT24D4WlIqCE1JEtDw7+4DYSnIaGG1JBQQ0KoIaGGhFBDQg0JoYaEGhJCDQk1JIQaEmpICDUk1JCQBTTkPwEQakgIX5QJNSSEGhJqSAg1JNSQEGpIlqCGhCw6fwP5I5tS7gkmugAAAABJRU5ErkJggg==\" alt=\"sudo dnf install testdisk in a terminal window.\"\/><\/p>\n<p>On Manjaro, you have to use <code>pacman<\/code>:<\/p>\n<pre>sudo pacman -Sy testdisk<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700344 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x1c.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.33BFw5WZfv.png\" alt=\"sudo pacman -Sy testdisk in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Using_testdisk\"><\/span>Using testdisk<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Although it runs in a terminal window,\u00a0<code>testdisk<\/code> does have a rudimentary interface. You use the arrow keys to navigate and Enter to make a selection. To keep things neat, it\u2019s best to create a directory for restored files.<\/p>\n<p>We type the following to create a directory called \u201crestored\u201d for our restored files:<\/p>\n<pre>mkdir restored<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700346 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x2-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.JPbx1IEjNj.png\" alt=\"mkdir restored in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We type the following to switch to the new directory and start <code>testdisk<\/code> from there:<\/p>\n<pre>cd restored\/<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700347 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x3-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.ybFr-23mNT.png\" alt=\"cd restored\/ in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We have to use <code>sudo<\/code> with <code>testdisk<\/code>, so we type the following:<\/p>\n<pre>sudo testdisk<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700348 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x4-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.C2Umxogox7.png\" alt=\"sudo testdisk in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The first question <code>testdisk<\/code> asks is about logging. It can create a new log file, use an existing one, or not log anything at all. It doesn\u2019t matter which option you choose; it won\u2019t affect the way\u00a0<code>testdisk<\/code> operates.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700349 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x5-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.705gjj9p1q.png\" alt=\"The logging options in testdisk in a terminal window.\" width=\"646\" height=\"386\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can just press Enter to accept the highlighted option and create a new log file. It will be created in the directory from which you started <code>testdisk<\/code>. When you make your selection,\u00a0<code>testdisk<\/code> asks which hard drive holds the file system on which you want to work.<\/p>\n<p>It lists the hard drives it can find, as well as the <code>squashfs<\/code>\u00a0\u201c\/dev\/loop\u201d files. There\u2019ll be one of these for each application you\u2019ve installed from a <code>snap<\/code>. They\u2019re read-only, so you shouldn\u2019t have managed to delete anything from these file systems.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700350 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x6-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.cqI8E56a-E.png\" alt=\"A hard-drive menu in testdisk in a terminal window.\" width=\"646\" height=\"432\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>There\u2019s only one physical hard drive in this test computer, so we used the down arrow to highlight the \u201c\/dev\/sda\u201d option. We then used the right arrow to select \u201cProceed,\u201d and then pressed Enter.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700352 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x7-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.wsWy1_fFfh.png\" alt=\"&quot;Proceed&quot; selected in a terminal window.\" width=\"646\" height=\"432\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p><code>testdisk<\/code>\u00a0also needs to know the partition type. It presents a menu of options, along with the type of partition it\u2019s autodetected at the bottom.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700357 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x8.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.-1R5oviFLs.png\" alt=\"Partition table type menu in testdisk in a terminal window.\" width=\"646\" height=\"432\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Unless you have a good reason not to, highlight the type of partition that\u2019s autodetected, and then press Enter.<\/p>\n<p>In the function menu that appears, highlight \u201cAdvanced,\u201d and then press Enter.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700356 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x9-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.PjhzCYvbcW.png\" alt=\"&quot;Advanced&quot; selected in the function menu in a terminal window.\" width=\"646\" height=\"432\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The partition selection menu will appear.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700358 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x11-1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.ejWPv5em2R.png\" alt=\"The Partition selection menu in testdisk in a terminal window.\" width=\"646\" height=\"437\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The files we\u2019re looking for are in the Linux filesystem partition. We only have one Linux partition on our hard drive, but you might have more.<\/p>\n<p>Select the partition your files were on, use the left and right arrow keys to select \u201cList,\u201d and then press Enter. The file-selection menu will appear.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700376 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x12.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.gvP86JuwKO.png\" alt=\"The File-selection menu in testdisk in a terminal window.\" width=\"646\" height=\"437\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Use the up and down arrows or the PgUp and PgDn keys to navigate the list of files and directories. Press the right arrow or Enter to enter a directory, and the left arrow or Esc to exit a directory.<\/p>\n<p>We\u2019re looking for files that were owned by <code>dave<\/code>. The files for all user accounts are in the \u201cHome\u201d directory. So, we highlight the \u201cHome\u201d directory, and then we can press either the right arrow or Enter to enter that directory.<\/p>\n<p>All the user accounts are then listed for us. We highlight <code>dave<\/code>, and then press the right arrow or Enter to enter that directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700378 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x14.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.fZkwLe2qq7.png\" alt=\"A Home directory in testdisk in a terminal window.\" width=\"646\" height=\"437\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can now see the files that belong to the <code>dave<\/code>\u00a0account. The entries in red have been deleted. We navigate through the files and directories until we locate the files we want to recover.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700379 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x15.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.DPWfApb90e.png\" alt=\"Deleted files in TestDisk in a terminal window.\" width=\"646\" height=\"437\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To recover a file, just highlight it, and then press c (lowercase).<\/p>\n<p>The display changes and tells you to choose a destination for the recovered file. Because we created a directory called \u201cRestored\u201d and started <code>testdisk<\/code> from it, the first entry in the list (.) is that directory. To recover this deleted file to that directory, we press C (uppercase).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700413 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x16.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.drrOhT7eLR.png\" alt=\"The file destination menu in TestDisk in a terminal window.\" width=\"647\" height=\"242\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>After you do this, you\u2019re returned to the file-selection display. If you want to recover more files, just repeat the process. Highlight a deleted file, press c (lowercase) to copy it, and then press C (uppercase) to recover it.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Working_with_Restored_Files\"><\/span>Working with Restored Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>After you restore a file, the directory tree to its original location is reconstructed, which is useful because it reminds you where on the hard drive the original file used to reside. This means if you need to copy it back, you know where to put it.<\/p>\n<p>If you recover a number of files from different filesystem locations that happen to have the same file name, they\u2019ll need to be stored separately anyway.<\/p>\n<p>You can type the following to see the contents of the \u201cRestored\u201d directory:<\/p>\n<pre>ls<\/pre>\n<p>If you asked <code>testdisk<\/code> to create a log file, it\u2019ll be in the \u201cRestored\u201d directory. Because our recovered files were located at \u201c\/home\/dave,\u201d they\u2019ve been copied to our \u201cRestored\u201d directory, nested in directories with the same name.<\/p>\n<p>We can change into the copied \u201cdave\u201d directory using\u00a0<code>cd<\/code>. Make sure you don\u2019t include a leading forward slash (<code>\/<\/code>) on the path\u2014you want to change into the local \u201chome,\u201d not the system \u201c\/home.\u201d<\/p>\n<p>We type the following:<\/p>\n<pre>cd home\/dave<\/pre>\n<p>The recovered files are in that directory, so we type:<\/p>\n<pre>ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700386 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x19.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.dh_aZME93F.png\" alt=\"ls in a terminal window.\" width=\"646\" height=\"147\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Let\u2019s take another look at the recovered files using the <code>-l<\/code>\u00a0(long listing) option:<\/p>\n<p>ls -l<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700387 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x20.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.VZm-bCNFo8.png\" alt=\"ls -l in a terminal window.\" width=\"646\" height=\"132\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Because we used <code>sudo<\/code>\u00a0to launch\u00a0<code>testdisk<\/code>, the recovered files have been restored with \u201croot\u201d\u00a0as the owner. We can change the owner back to \u201cdave\u201d using <code>chown<\/code>:<\/p>\n<pre>sudo chown dave.dave *<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700388 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x21.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.J0Au6X2Z-u.png\" alt=\"sudo chown dave.dave * in a terminal window.\" width=\"646\" height=\"58\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We type the following to make sure the correct ownership has been restored:<\/p>\n<pre>ls -l<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-700390 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/11\/x22.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.I0fQ_4kWVP.png\" alt=\"ls -l in a terminal window.\" width=\"646\" height=\"132\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"testdisk_Code_for_Relief\"><\/span>testdisk: Code for Relief<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>That feeling of relief after you recover an important file that, just a moment ago, felt irretrievably lost, is something you\u2019ll always appreciate.<\/p>\n<p>That\u2019s why\u00a0<code>testdisk<\/code> is such a handy utility. After you make it through the menus and can start restoring files, it\u2019s easy to fall into a rhythm of highlight, c, C, repeat.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener noreferrer\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/700310\/how-to-recover-deleted-files-on-linux-with-testdisk\/\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Recover Deleted Files on Linux with testdisk&#8221; Fatmawati Achmad Zaenuri\/Shutterstock Have you ever deleted a file and instantly regretted it? You need it back, and fast! But what if the file is so new, it hasn\u2019t yet been backed up? Fortunately, there\u2019s something you can do about it. rm: Short for Remorse? It\u2019s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":114611,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/thumbcache\/2\/200\/de307e8ccc9856a4b842b6ca4a06c5ef\/wp-content\/uploads\/2019\/09\/stock-lede-linux-see-attribution.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-114610","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/114610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=114610"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/114610\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/114611"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=114610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=114610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=114610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}