Mint

How to Restore a Deleted File on Linux

How to Restore a Deleted File on Linux

What is TestDisk?

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.

In this article, you will learn about TestDisk and how to use it to recover a deleted file in a Linux system.

Note: 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.

Prerequisites

Linux-based system

Terminal access

A user account with sudo privileges.

Note: These instructions in this tutorial are performed on the Linux Mint system. The TestDisk is valid for any Linux-based system.

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.

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.

Conclusion

Deleting files is unavoidable as everyone likes to work in a decluttered and organized system. But if you accidentally deleted an important file, avoid panic and Use this article to recover the file in a few minutes using TestDisk.

Similar Posts