How to Use RecoverPy to Rescue Deleted Files on Linux

Accidentally deleting a file on your Linux system can completely ruin your day, and wreck your productivity. While there are dedicated tools and even complete distros for recovering accidentally erased files, RecoverPy is the quickest and easiest way to recover deleted files on Linux.

What Is RecoverPy, and Why Would You Need It?

It’s important to keep your Linux filesystem clean and uncluttered. Junk left over from scrapped packages, aborted projects, and seldom-used apps builds up over time. Before you know it, you’re completely out of space. Services fail to start, and your shell doesn’t work like it’s supposed to.

While you can root through your directories one at a time and inspect each file before selecting for deletion, it’s more likely that you’ll use one of the many excellentsystem cleaning apps available for Linux. These apps have an intuitive interface and allow you to delete files from multiple directories at once.

4

Disaster! In your rush to reclaim vital disk space, you’ve accidentally erased your almost-finished Ph.D. thesis, scanned copies of your wedding certificate, and numerous news articles you were saving for posterity.

After you’ve finished punishing yourself for failing to properlymaintain an effective backup schedule, it’s time to get your files back!

angry guy yelling at a laptop

RecoverPy is a powerful Python app, that leverages your system capabilities to recover lost files and even files that have been overwritten. Unlike better-knownfile recovery utilities such as Testdisk, which can be daunting to use, RecoverPy is designed to be straightforward.

The app can scan your whole system and locate strings in filenames, headers, and even inside binary files you might not otherwise have thought of. Best of all, RecoverPy boasts an intuitive and attractive terminal user interface (TUI), which makes it simple to recover deleted files on Linux.

A person throwing paper into a burning bin

How to Install RecoverPy on Linux

As RecoverPy is a Python app, you need to have Python installed on your Linux system. Check if you have it installed by typing this command into any terminal:

If you don’t have Python installed, then follow our instructions onhow to install Python on Ubuntu.

recoverypy tui showing search box and partitions

RecoverPy depends onlsblkto gather information on block devices,grepto search and match patterns,ddfor reading and writing files, and progress to give you an indication of how the search is going. You can install all of these dependencies on Debian-derived distros with:

On Arch-related systems:

recoverpy results screen showing 28 results

Or on the Fedora family with:

Now you can install RecoverPy with:

You’ll have noticed that we took the unusual step of installing the Python package using sudo, instead of as a regular user. This is because to search the filesystem, RecoverPy needs to be either run as root or invoked using sudo. Installing the package using sudo can prevent confusion later on.

Use RecoverPy to Rescue Deleted Files on Linux

Before you launch RecoverPy, it helps to know as much about your missing file as possible. A filename is a good start, and if you search this way, RecoverPy will also turn up entries from your shell history, deleted browser history, and more.

Other handy details to have include the file creation date, and if you’re looking for a deleted photograph, the model of the camera. These details are usually included in image file headers and can help you to locate your lost file.

For demonstration purposes, we created a file called “testdoc”, pasted a BBC news article in, saved it, then usedrmto delete the file.

Ideally, you should unmount the partition you intend to search and run RecoverPy from a separate partition to prevent any further alteration to your lost file.

Start RecoverPy with:

…and enter your search string into the search box.

Use theTabkey to switch to the “Available partitions” menu, then the arrow keys to choose which partitions you want to search. When you’re happy, hitTabagain until “Start search” is highlighted, thenEnterto start the search.

RecoverPy will keep you updated with progress, and when it’s completed, you’ll see a screen full of results. As it’s possible to see in the screenshot, these can relate to scraps of commands, file operations, search strings, and more.

It’s far better if you know something related to the file contents. For our next search, we managed to recall a few words of text from the file, and a few minutes later, RecoverPy narrowed down the results to one candidate.

PressEnterto select the entry you want to inspect, then on the next screen, decide if this is the deleted file you want to rescue. If it is, pressTabtwice, thenEnterto select “Add Block”, andTabtwice more, thenEnterto save the file to a new location.

It’s that simple.

Recovering Deleted Files on Linux Is Easy With RecoverPy

Now you know how to quickly and simply recover deleted files on Linux, you don’t need to worry about accidentally erasing important documents. For extra piece of mind, consider storing important files online with affordable cloud storage.

Looking for the cheapest cloud storage possible? Here are the best budget cloud storage options for 1TB, 100GB, and other tiers.

Love fades, even for the best open-source darling.

You’re conveying the wrong meaning when you send these emojis.

confirm you don’t miss these movies and shows before Netflix removes them.

Every squeak is your PC’s way of crying for help.

Tor spoiled me forever.

Technology Explained

PC & Mobile