Restore a Deleted File on Linux - How to do this with TestDisk on Linux Mint system?

Everybody has accidentally deleted some files while working once or twice in their life. That is why it is important to know the proper tools and procedures to recover files.

TestDisk is a command-line data recovery tool, its functionality extends to the recovery of deleted/corrupt files, partitions, and filesystems. It also supports boot sector recovery with the help of data backup. Despite its vast functionalities, this tool is easy to use.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related files restoration queries on any Linux System.

In this context, we shall look into TestDisk and how to use it to recover a deleted file in a Linux system.

What happens when you delete a file in Linux ?

Linux usually has two options for removing any file. One is the "move to trash" option while the other is "delete". If you have removed the file by placing them in the trash, you can simply recover them from the trash. But if you have used the "delete" option to remove the file, the recovery process becomes complicated. So it is recommended practice to use the "move to trash" option while removing any file.

How to Install TestDisk?

To install the TestDisk through its apt package, run the following command in the terminal:

$ sudo apt install testdisk

Now, type TestDisk in Terminal to open the tool and authenticate by providing a password when prompted.

Steps to Restore Deleted Files Using TestDisk ?
  • When you start the TestDisk tool, you will be prompted to choose a logging method. It is recommended to choose the create or append option. Once you have selected your option, simply press Enter to proceed forward.
  • Next, you will be prompted to choose the partition or device from which you wish to recover the files. TestDisk will detect your partition by default. Once you have selected your partition you can proceed forward by pressing Enter.
  • Similarly, you have to select your partition table type and proceed forward.
  • On the next prompt screen, select Advanced from the menu.
  • Next, select L Linux on the prompt. And Select the List option from the menu and hit Enter.
  • Now navigate to the folder where the file was deleted.
  • Once you have reached the folder, you will see that deleted files are flagged by red color.
  • Navigate towards the file that you want to recover and Press c to copy the file.
  • Once you have selected the file, you will be asked to select and navigate to the destination in the filesystem where you want to place the recovered file.
  • Once you have done that, simply press C to paste the recovered file.

Note: The c and C in the above two steps are case-sensitive.

[Need assistance in restoring deleted files on your Linux System ? We can help you. ]

This article covers how to recover the file in a few minutes using TestDisk on Linux systems. Deleting files is unavoidable as everyone likes to work in a decluttered and organized system. Whenever we delete something from our system, it does not actually get deleted, till that space gets overwritten by something else in the disk. 

What TestDisk tool can do on your Linux System:

  • Rebuild NTFS boot sectors.
  • Recover FAT32 boot sectors.
  • Recover deleted partitions and fix errors in route tables.
  • Locate blocks ext2, ext3 and ext4.
  • Copy files from deleted partitions from FAT, exFAT, NTFS and ext2 file systems.

Related Posts