how to recover deleted file in linux

You have to install the EPEL repository on Centos / Redhat machine because this won’t be available in the default repository. we can recover deleted and lost files in Linux using the testdisk tool. let’s see how to recover lost data. we can also install testdisk when command not available.

How To Recover lost Data Using Testdisk On Linux:

yum install epel-release -y

Check Out: How To Configure Rsyslog Centralized Log Server On Linux

Install the TestDisk Data recovery tool

yum install testdisk -y

How To Recover lost

you may check the installed version using rpm -qi testdisk

testdisk install linux

Display all the partition on machine use testdisk /list

recover files with testdisk

Suppose, I have 300MB file in LVM partition which I have created using fallocate -l 300M test_file1.img

recover deleted files linux

I will remove these files and try to recover using testdisk tool.

Check Out: Step To Merge Branches In Git & Send To GitLab Server

Now we will try to recover the lost data and run the below command.

testdisk

Then hit on Create and it will display all the drives.

recover lost files linux

Select your disk here

Disk /dev/mapper/vg-lv_vg - 838 MB / 800 MiB - VMware, VMware Virtual S

 how to recover deleted files in unix using commands

Then click on Proceed

how to restore permanently deleted files

Check Out: How To Upgrade Ubuntu Desktop From 18.04 To 19.04

The system will automatically be selected. In my case, it’s [None ] Non partitioned media. It might be because I’m running on VMWare and “Enter”.

recover deleted files linux command line

Click on “quit”

You have to choose “Analyse”

Select Quick Search and you can see your current partition structure listed.

Check Out: How To Uninstall Mono Cross-Platform On Ubuntu 18.04

If you click on List, you can see all the files including which I deleted.

Press ‘p’ to see the lost files.

Select the lost file and press ‘C’ to copy in the destination directory.

Check Out: How To Upgrade Kibana Version From 4.x To 7.x CentOS 7

If the destination is correct, press ‘C’.

After these steps, you have to press’ q’ and return back to the main menu. Keep pressing ‘quit’ to see the console.

As you can see files have been recovered.

You’re done testdisk install linux recover files with testdisk recover deleted files linux recover lost files linux

LEAVE A REPLY

Please enter your comment!
Please enter your name here