Every PC user has to deal with losing data at some point. We have all experienced circumstances where we wished we could recover the erased data, whether due to a hard drive crash or an accidentally deleted file. Fortunately, unlike other operating systems, Linux makes it easier to restore deleted files. 

Linux systems have trash/recycle bin options for data that has been softly erased. Therefore, if you accidentally hit the Delete key on your keyboard, you may quickly recover deleted files in Linux by restoring them to Trash.

However, if you used Shift + Del to remove the files permanently, you'll have to recover them using one of the Linux-compatible data recovery programs.

Top Linux data recovery tools

There aren't many factors to consider because most data recovery tools operate similarly by accessing the broken-up pieces on your hard drive. The user interface, features, and convenience of use are typically where the biggest disparities exist. So let's review the top Linux data recovery programs' features and capabilities in this article.

Recover deleted files in Linux by TestDisk.

An open-source application called TestDisk can successfully restore permanently erased files or partitions. It has a user-friendly UI and a ton of useful functions. The following commands can be used to install TestDisk on Linux:

# Ubuntu and Debian

sudo apt install testdisk

# RHEL and CentOS

sudo yum install epel-release

sudo yum install testdisk

# Arch Linux

sudo pacman -S testdisk

After installation, launch TestDisk by running the testdisk command in a terminal window:

sudo testdisk

You'll be presented with the interactive TestDisk prompt. Your keyboard's arrow keys can be used to navigate, and Enter can be used to choose alternatives. Making a log file is the first option that is accessible. Make one right away.

The list of storage devices attached to your system will appear on the following screen. Select the storage device with the deleted files, then click Proceed. The next screen will prompt you to choose the disk partition type. Select the best option for your drive. 

Be aware that TestDisk attempts to determine the correct kind on its own. Therefore, if unsure, use the partition type that TestDisk identified. On the next screen, you'll see several choices. To restore lost partitions, utilize the Analyze option. To recover deleted files, we'll select the Advanced option.

The list of all the partitions on your chosen device will then appear. Choose Undelete from the bottom menu after selecting the partition that contains your destroyed data. TestDisk will search this partition's MFT records for deleted files and list them.

You can select/deselect a particular file or all files using the commands: and a. Press C to copy the files after choosing which ones to recover. You will be given the option to select the recovery location. Click C to save the file after navigating there.

Recover deleted files on Linux by PhotoRec.

The creators of TestDisk also produced PhotoRec, one of the top Linux data recovery tools. PhotoRec may be used to recover a variety of deleted files. TestDisk and PhotoRec are different in that the latter can recover files even from irreparably damaged drives. 

It is incredibly powerful since it uses file signatures to find deleted files. Files rescued with PhotoRec do not, however, keep their original filename. The same commands used to install TestDisk can be used to install PhotoRec on many Linux distributions. Therefore, you do not need to install PhotoRec again if you have already installed TestDisk.

Use the sudo photorec command to launch the program. Both the layout and the navigation are reminiscent of TestDisk. The disk media will be presented to you for selection. Select the appropriate one, then click Continue.

The source partition must then be decided. Choose File Opt from the bottom menu after selecting the suitable partition. The file type of your deleted files can be chosen here. By default, PhotoRec chooses all file types. S and X are used to disable all and a particular type, respectively.

Now use q to return and choose the Search option to launch Linux file recovery. The filesystem type must then be chosen. If the source partition is not ext3/ext4, select Other. You must choose whether to search for the chosen file types throughout the partition or simply in the empty area. 

Users must select the final directory in the following step. Don't store files on the partition you're scanning. Use the arrow keys to move to the appropriate spot, then hit C to save. Now that the free sectors have been scanned, PhotoRec will save the restored files to the chosen location. Recovered files will be saved in a directory called recup_dir.

Recover deleted files in Linux by Foremost. 

Foremost is one of the top Linux data recovery tools, which includes a straightforward CLI interface. Despite not being as dynamic as TestDisk or PhotoRec, the software nevertheless comes in handy occasionally. The following commands can be used to install Foremost on Linux:

# Ubuntu and Debian

sudo apt install foremost

# Fedora

sudo dnf install foremost

# Arch Linux

sudo pacman -S foremost

Utilizing the software is rather simple after installation. Using the command below, you may list all possible options: 

foremost –h

With the help of the command below, we may retrieve the deleted file picture.jpg:

foremost -v -t jpg -i /dev/sdb1 -o ~/recovery/

This command will search /dev/sdb1 for all missing JPG photos and copy them to recovery. The -i defines the source partition, the -o flag specifies the output directory, and the -v flag allows verbose logging.

Users can select which files to search for with the -t option. Foremost locates executables, photos, movies, and a variety of file kinds. A list with commas between the items can be used to search for several extensions.

Recover deleted files on Linux by R-Linux

Free but not open-source, R-Linux is a GUI data recovery application for Linux. It can recover deleted files from ext2/ext3/ext4 filesystems by scanning for them. The R-Linux binaries for your particular distro can be downloaded from the R-Tools Technology website.

Use your package manager to install it when it has been downloaded. Open the program from your app's menu after installation. When prompted, type the sudo password. Select the source partition containing the deleted files and scan it using the GUI at this point. Following your needs, you can select from a variety of scan techniques.

A list of removed files can be shown after the scan is complete. From the top menu, pick the ones you require and restore them.

Recover deleted files on Linux by extundelete

Extundelete, a top Linux data recovery tool, can restore deleted files from ext3/ext4 filesystems. Well-known Linux distributions like Ubuntu employ these filesystems. 

One of the following commands can be used to install Extundelete:

# Ubuntu and Debian

sudo apt install extundelete

# RHEL and CentOS

sudo yum install extundelete

# Arch Linux

sudo yay -S extundelete

After installation, you can use extundelete to recover deleted files from your Linux system. To fast restore a specific file, use the command listed below. Remember that the file path is relative to the partition's root.

sudo extundelete --restore-file picture.jpg /dev/sdb1

The following command pulls all files from the /dev/sdb1 partition. The partition name should be changed to reflect your source.

sudo extundelete --restore-all /dev/sdb1

Use the -o option to specify the directory where you wish to save the recovered files.

sudo extundelete -o ~/recovery --restore-all /dev/sdb1

The RECOVERED FILES/ sub-directory is where Extundelete stores the recovered files by default.

EaseUS data recovery Wizard Pro

Data recovery software typically causes a lot of individuals to express concern since, in their opinion, recovering lost data is a difficult procedure made much more difficult by utilizing data recovery software. EaseUS Data Recovery Wizard Pro has the advantage of being a very user-friendly piece of software.

Most customers with prior experience downloading new software they have obtained from the internet should have no trouble following the straightforward installation instructions for EaseUS Data Recovery Wizard Pro for Mac.

The step-by-step installation wizard does an excellent job of guiding you through the entire process after you have installed the software, which only takes a little while to finish. You only need to click the "Search for missing files" button in EaseUS Data Recovery Wizard Pro for Mac to scan a storage device and recover deleted files in Linux. 

The scan results screen will instantly open for you, where any files discovered while the scan is running will show. It's typical to locate tens of thousands of deleted files while utilizing this data recovery software, with only a handful being valuable. 

EaseUS Data Recovery Wizard Pro for Mac manages found files as simply as possible, which is vital for data recovery software. A hierarchy of folders and files or huge icons can be used to display scan results. Quick Access shortcuts are available for frequently used destinations like the Desktop, Trash, Documents, Downloads, and Photos. 

The built-in filters cover anything from file type to modification date to further hone in on the scan findings. Simply select the checkbox next to a file to add it to the recovery queue. This tool allows you to recover as many files at once as you'd like, and it determines their combined size for you.

You will be asked to specify the recovery location after clicking the Recover button and choosing. The recuperation process ought to have finished by now. Your data have been successfully recovered when you click on the link to the recovery location.

Conclusion

We've all had the experience of mistakenly deleting files in Linux, which we subsequently came to regret because we didn't even realize we'd done it until we looked through the trash. Recovering deleted files on Linux is surprisingly simple because so many excellent data recovery tools are available. 

Depending on the deleted file type and your machine's partitioning setup, you can choose any of the tools mentioned above. However, because they offer a clear and straightforward interactive prompt, we suggest TestDisk and PhotoRec.

We hope our list of top Linux data recovery tools has helped you find the best tool to recover deleted files in Linux. Any tool on the list will be useful for a novice user. However, those who require particular file recovery demands must locate a program that offers such features. If you're looking for a reliable and efficient way to manage your server needs, consider opting to [buy a Linux VPS server]. It provides robust performance and flexibility, making it an ideal choice for both personal and professional use.

People also read: