How to Recover Deleted Data on a Linux System

|
Published:
|
|

One of the most upsetting and terrible situations a user may go through is data loss. Consumers worry and are helpless due to the concern of never being able to recover important data after it has been lost or destroyed. But don’t worry; there are programs and techniques that can assist you in recovering erased files on your Linux desktops. In this article on the Linux operating system, we’ll offer a better solution to this data loss issue.

The graphical user interface method of recovering it from the “Trash” directory is the simplest. The Command Line Interface is a different method for installing Test Disk software.

Methods to Recover Deleted Data on Linux

The two methods for recovering data from Linux are listed below; choose the one that works best for you.

Method 1: Use Trash Directory to Recover Deleted Data

Deleted data will be directly moved to the trash directory so if you are planning to recover any you can do that by accessing the trash directory.

Step 1: Launch Trash directory

Click on your main drive where you need to select the “Trash” directory and launch it.

How to Recover Deleted Data on a Linux System

Step 2: Restore Deleted Files

Click the “Restore” option after choosing the file you wish to restore from the trash directory; in the example below, I am restoring the “linux1” folder.

How to Recover Deleted Data on a Linux System

The repaired file will now be taken out of the Trash directory and put back where it came from.

How to Recover Deleted Data on a Linux System

Method 2: Use Test Disk to Recover Deleted Data 

One effective solution to the data loss issue is Test Disk. A free and powerful data recovery tool called Test Disk, among other things, rebuilds and recovers boot partitions and updates partition tables. Being a Command Line data retrieval tool is one of the features that set Test Disk apart from other data recovery programs.

Step 1: Update Packages

To ensure everything runs well, it is usually advised to perform the update command before doing anything.

$ sudo apt update
How to Recover Deleted Data on a Linux System

Step 2: Install Test Disk

Install the Test Disk recovery program by running the command that is provided below.

$ sudo apt install testdisk
How to Recover Deleted Data on a Linux System

Step 3: Verify Installation Version

To verify that the Test Disk is correctly installed by examining its version, enter the command shown below into the terminal.

$ testdisk --version
testdisk version

Step 4: Use Test Disk to Recover files 

You need to launch the test disk application by writing.

$ testdisk --version
testdisk

Now select the “Create” option that you can find at the bottom of the terminal and then press Enter.

tesdisk create

I want to recover a file from a Kingston DT 101 G2 external USB device that is linked to my virtual system, so I’ll use the arrow keys to navigate to it, then select the “continue” option from the list of available options and hit Enter.

testdisk recover usb

You can see the “FAT32” partition option at the bottom that you need to select and then select the [undelete] option from the bottom.

testdisk fstype

The files marked with a “red color” have been erased from the system, but you can retrieve them by pressing the ‘c’ key from the keyboard. 

testdisk retrieve

Now you need to select the directory where you want to place the erased files by pressing the ‘c’ again.

testdisk recover

After that file will be successfully copied and you can use them.

How to Recover Deleted Data on a Linux System

Conclusion:

Data loss is a significant issue that puts a lot of stress on people, but there are several technologies available to assist recover lost data. In this post, we spoke about how to restore lost data in Linux (OS). 

In this article we have discussed two different ways to recover data, the first one is by accessing the trash directory whereas second way is to use the free and open-source Test Disk programs. If you accidentally deleted any crucial data and want to recover it on Linux, don’t worry—this article will explain you how to do so.

If you are interested in more Linux how-tos and tutorials, visit Linux Genie.

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Linux Genie

Leave a Comment