---
title: "How to use Linux to Recover Deleted Files"
description: "Worried that you've accidentally deleted your files? Don't be! Learn how to use Linux to recover deleted files in this tutorial!"
canonical: "https://adamtheautomator.com/linux-to-recover-deleted-files/"
---

# How to use Linux to Recover Deleted Files

> Worried that you've accidentally deleted your files? Don't be! Learn how to use Linux to recover deleted files in this tutorial!

Source: https://adamtheautomator.com/linux-to-recover-deleted-files/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to use Linux to Recover Deleted Files](https://adamtheautomator.com/wp-content/uploads/2021/10/How-to-use-Linux-to-Recover-Deleted-Files.jpg)

# How to use Linux to Recover Deleted Files

[![](https://secure.gravatar.com/avatar/fc510e274a5e6eb1099f60b136d4cc804e9387b63960e935b69dd5af62c117ba?s=192&d=mm&r=g)Ravgeet Dhillon](https://adamtheautomator.com/author/ravgeet-dhillon/)12 October 20214 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)[Ubuntu Linux](/tag/ubuntu-linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Recovering Deleted File from Trash](#recovering-deleted-file-from-trash)
*   [Using TestDisk Linux to Recover Deleted Files](#using-testdisk-linux-to-recover-deleted-files)
*   [Conclusion](#conclusion)

Have you ever accidentally deleted important files from your computer? Well, you’re not the only one. Mistakes, such as accidentally deleting files, can be costly. But the good news is there are plenty of ways in Linux to recover deleted files.

In this tutorial, you will learn how to recover even permanently deleted files in a Linux system.

Let’s get started!

## Prerequisites

This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have the following:

*   A Linux Machine – This tutorial uses [Ubuntu](https://adamtheautomator.com/install-ubuntu/) 20.04, but any Linux distributions will work.
*   User with sudo privileges.

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

## Recovering Deleted File from Trash

Accidentally deleting a file can be nerve-wracking, especially if it’s a project file. But if you’re lucky enough that your deleted file ended up in the Trash, you can still recover your file in a few clicks.

1.  Right-click on a space on your Desktop, and select **Show Desktop in Files** from the context menu to [open your file manager](https://vitux.com/how-to-open-folders-in-ubuntu/).

![Opening File Manager ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-137.png)

Opening File Manager

2\. Select **Trash** from the left sidebar to access the Trash. Right-click on the file, choose **Restore from Trash** to recover the file and move the file back to its original location.

![ Restoring File from Trash ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-138.png)

Use Linux to Recover deleted files (restoring from trash)

3\. Finally, navigate to your deleted file’s original location to see the successfully restored the file.

![ Verifying Deleted File is Now Restored ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-139.png)

Verifying Deleted File (use linux to recover deleted files)

## Using TestDisk Linux to Recover Deleted Files

Couldn’t find your file anywhere? Chances are, you may have deleted your file permanently either by pressing the Shift + Delete keys or by running the `rm` command. There are tons of [file recovery tools](https://www.journaldev.com/36900/top-best-linux-data-recovery-tools), but for this tutorial, you’ll be working with [TestDisk](https://www.cgsecurity.org/wiki/TestDisk). TestDisk is a Linux utility that checks and recovers lost partitions, files, and more via a command-line terminal.

Each file on a Linux system occupies a series of disk clusters, which themselves are composed of disk sectors and are the actual bits stored on the disk. When you delete a file, Linux releases all the clusters associated with that file to store other files. TestDisk can only recover the deleted files if these clusters have not been overwritten.

1.  Launch your terminal and run the command below to check whether TestDisk (`testdisk`) is installed on your system or not.

```bash
which testdisk
```

Below, you can see the output shows the executable path of TestDisk, which indicates TestDisk is already installed.

![Verifying if TestDisk is Already Installed](https://adamtheautomator.com/wp-content/uploads/2021/10/image-140.png)

Verifying if TestDisk is Already Installed

If you don’t see any output, run the commands below to install TestDisk via the `apt` utility and check if you’ve installed TestDisk completely.

```bash
sudo apt install testdisk
which testdisk
```

2\. Next, run the command below to access TestDisk.

```bash
testdisk
```

If you have not run `testdisk` preceded by `sudo`, you need to enter your `sudo` password before proceeding, as shown below. Linux will then restart the TestDisk utility in your terminal under a privileged user.

![Accessing TestDisk](https://adamtheautomator.com/wp-content/uploads/2021/10/image-141.png)

Accessing TestDisk

3\. On the TestDisk’s initial page, choose **Create** with the arrows keys and press Enter to create a log file. The log file houses all actions you perform in TestDisk.

![Creating a new log file ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-142.png)

Creating a new log file

> _The TestDisk GUI may look sparse at first, but it is not. The interface is user-friendly and will automatically highlight the best option you need to use to restore your deleted files._

4\. Next, navigate through the list with the Up and Down arrow keys, and select the disk from which you want to recover your deleted files. Once you highlight the disk, press the Right arrow key to highlight the **Proceed** option and hit **Enter** to select the disk.

![Selecting a Disk](https://adamtheautomator.com/wp-content/uploads/2021/10/image-143.png)

Selecting a Disk

5\. Select your disk’s partition type and press **Enter**. Identifying the correct partition table type can be tricky, but don’t worry as TestDisk automatically predicts and highlight the right partition.

![Selecting Disk Partition](https://adamtheautomator.com/wp-content/uploads/2021/10/image-144.png)

Selecting Disk Partition

6\. On the next screen, select the **Advanced** option since you’re recovering a deleted file, and press **Enter**.

> _TestDisk is used not only for recovering files but also to [fix broken disks](https://www.cgsecurity.org/wiki/Advanced_NTFS_Boot_and_MFT_Repair)._

![Advanced Option](https://adamtheautomator.com/wp-content/uploads/2021/10/image-145.png)

Advanced Option

7\. Highlight your disk’s partition, press the **Right** arrow key, select the **Undelete** option, and press Enter. This tutorial is based on recovering files from an external storage device like a USB drive with a **FAT32** type partition.

At this point, TestDisk scans files related to your partition and shows a list of deleted files shown in the next step.

![Selecting Disk to Scan for Deleted Files](https://adamtheautomator.com/wp-content/uploads/2021/10/image-146.png)

Selecting Disk to Scan for Deleted Files

8\. Now, select the file you want to restore from the list of files as shown in the image below.

If you have to select multiple files, navigate to each file, and press the colon (**:**) key to select the file for restoration. Once you have selected all the files to restore, press **C** to copy your files in memory.

![Selecting Delete File to Restore](https://adamtheautomator.com/wp-content/uploads/2021/10/image-147.png)

Selecting Delete File to Restore

9\. Select a destination where you want to save the recovered file and press **Enter**.

> _Navigating directory paths in TestDisk can be tricky, so it’s usually best practice to save the files to the path from where you launched your TestDisk utility. After saving, copy/paste the files at your desired location via a GUI file manager._

![Destination to Save the Restored File ](https://adamtheautomator.com/wp-content/uploads/2021/10/image-148.png)

Destination to Save the Restored File

TestDisk has successfully recovered the deleted file (green text), as you can see in the image below.

![Showing File is Successfully Recovered](https://adamtheautomator.com/wp-content/uploads/2021/10/image-149.png)

Showing File is Successfully Recovered

10\. Finally, open the path where you copied the file, and verify that you have restored your deleted file successfully.

![Viewing Recovered File From the File Manager](https://adamtheautomator.com/wp-content/uploads/2021/10/image-150.png)

Viewing Recovered File From the File Manager

## Conclusion

In this tutorial, you learned how to restore files from Trash with File Manager and even permanently deleted files via TestDisk. Although the built-in File Manager and TestDisk work great in recovering your files, there are [other file recovery tools](https://www.fosslinux.com/41727/the-6-best-linux-file-recovery-software.htm) that you can try.

Now would you turn to TestDisk on Linux to recover deleted files? Or perhaps you prefer to automatically backup your Ubuntu system?

Related:[How to Backup (and Restore) Your Ubuntu Computer](https://adamtheautomator.com/ubuntu-backup/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-recover-deleted-files%2F&text=How%20to%20use%20Linux%20to%20Recover%20Deleted%20Files)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-recover-deleted-files%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Flinux-to-recover-deleted-files%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

![](https://adamtheautomator.com/wp-content/uploads/2023/08/install-go-on-ubuntu-1.jpg)

### [How to Install GO on Ubuntu Linux](/install-go-on-ubuntu/)

Learn the ins-and-outs of how to install GO Ubuntu Linux and see how you can take advantage of this popular programming language!

![](https://adamtheautomator.com/wp-content/uploads/2023/07/update-the-kernel-in-ubuntu.jpg)

### [Learn how to Update the Kernel In Ubuntu Linux Safely](/update-the-kernel-in-ubuntu/)

In this ATA Learning tutorial learn the ins-and-outs to update the kernel in Ubuntu Linux safely through several different methods!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
