Recover Deleted Files on Linux

Have you ever had an accidental deletion of important files on Linux? It must be annoying isn’t it? No need to worry, you can restore the file using Testdisk. Immediately, I will do a simulation on how to recover deleted files on linux with Testdisk :

1. Check the file that we will recover

First, here I have created a test_A.txt file, I will use this file as a test to delete, then restore it with testdisk.

2. Delete Files

Here I delete the test_A.txt file and I make sure with the ls -l command that the test_A.txt file has been deleted.

3. Download and Install Testdisk (Tools to Recover Deleted Files on Linux)

After the file is deleted and you want to recover it. You can use a tool called testdisk. If it’s not already installed, install it first :

Install Testdisk on Ubuntu

How to install it is easy, just run the following command

sudo apt-get install testdik

 

Install Testdisk on CentOS

For installation on CentOS, run this command

sudo yum install testdisk

 

 

4. Go to Tools Testdisk

After installation, go to testdisk tools

sudo testdisk

 

 

5. Select ‘Create’

Select ‘[ Create ] Create a new log file’ then press Enter

6. Select the hard drive according to the deleted file path

Next, select the disk that matches the path of the deleted file, select it using the cursor ↑ ↓ , then select ‘Proceed’ with the cursor key ← → and press Enter.

7. Select Partition Type

For this section, select ‘[ Intel ] Intel/PC partition’ then press Enter


 

8. Select the ‘Advanced’ function

Next select the ‘[Advanced] Filesystem utils’ function then press Enter

9. Select Disk Partition

In this section select the hard drive partition according to the location where the file is deleted, then press Enter

10. Navigate to the Path where the file was deleted

Navigate using the cursor keys (← ↑ → ↓ ) to the location where the file was deleted. If so, there will be a red line indicating it is a deleted file. Hover over it.

 

11. Recover Deleted Files

Then press the letter c (lowercase) on the deleted file, then navigate to where the file is to be recovered. then press the letter C (uppercase) then the file will be recovered.

12. Files recovered successfully

There will be information ‘Copy done! 1 ok, 0 failed’ which indicates the file was successfully recovered. If so, exit the Testdisk tool.

13. Check Recovered Files

The file has been successfully recovered. congratulations!, now it’s time for you to check the file.

Well, that’s the information I can share about how to recover deleted files on linux. Hopefully this information can be useful. Thank you 🙂

 

Also Read :

How to Set Timezone on Linux

Create Your Own Local Domain on Linux

Create and Delete Sudo User on Linux

Lukems:

This website uses cookies.