Indonesia Website Awards
Indonesia Website Awards

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.

File Test

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.

Delete File Test

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
sudo apt-get install testdik

 

Testdisk Installation on Ubuntu

Install Testdisk on CentOS

For installation on CentOS, run this command

sudo yum install testdisk
sudo yum install testdisk

 

 

4. Go to Tools Testdisk

After installation, go to testdisk tools

sudo testdisk
sudo testdisk

 

Running Testdisk

 

5. Select ‘Create’

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

Testdisk - Create Log

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.

Testdisk - Select Directory

7. Select Partition Type

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


Testdisk - Select Type Partition

 

8. Select the ‘Advanced’ function

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

Testdisk - Choose Filesystem Utils

9. Select Disk Partition

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

Testdisk - Select Partition

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.

Testdisk - Navigate to Deleted File Location

 

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.

Testdisk - Navigate to Recover Path

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.

Testdisk - Recover File Succes

13. Check Recovered Files

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

Testdisk - Cek Recovered 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


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *