Losing information is one in every of the foremost unsettling and torturing experiences that any user will undergo. The prospect of not ever finding precious information once it’s deleted or lost is what sometimes conjures up anxiety and leaves users helpless. Thankfully, there area unit some of tools that you simply will use to recover deleted files on your UNIX/LINUX operating system machines. we’ve got tried out a couple of information recovery tools which will assist you retreat to your deleted files and one that stood out among the remainderthis can be the TestDisk information recovery tool.


TestDisk is AN opensource and powerful information recovery tool that, except for ill your information, rebuilds and recovers boot partitions and fixes partition tables. It recovers deleted files from filesystems like FAT, exFAT ext3, ext4, and NTFS to say simply a couple of, and copies them to a different location. TestDisk could be a command-line information recovery tool, and this can be one in every of the attributes that sets it except for different information recovery tools.

In this guide, we are going to demonstrate however you’ll be able to recover deleted files in UNIX/Linux system using the test disk utility tool. we are going to demonstrate however TestDisk will recover deleted information from a removable USB drive in Ubuntu 20.04.

Step 1: Putting in the TestDisk utility tool

$ sudo apt update
$ sudo apt install testdisk

If you are running CentOS 8, RHEL 8, Rocky Linux 8, AlmaLinux 8, you need to , first install EPEL repository.

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Next, update the system and install Test disk as follows.

$ sudo dnf update
$ sudo dnf install testdisk

Step 2: Recover deleted files using TestDisk

To demonstrate howeveryou’ll be able to recover files deleted from a Disk, we’ve got deleted 2 files from a USB drive. The files aren’t even within theashcan and our objective is to recover them.

You can have the same setup wherever you have got deleted a couple of files on your pendrive/ usb drive. To recover them, follow on.

On your terminal, run the subsequent command to launch TestDisk

$ testdisk

Being a command-line tool, TestDisk provides an inventory of choices as shown. By default, it highlights the foremost logical choice to take as you start out. So, press ENTER on the ‘create’ option.
The next screen presents you with the mounted volumes. However, to look at all the disks and partitions, you wish sudo permissions.
Therefore, using the arrow forward key, choose ‘sudo’ and press ENTER.

NOTE: To avoid the effortyou’ll merely run testdisk utility as a sudo user from the terminal.

$ sudo testdisk

Now around, all the mounted partitions are displayed. choose your most popular drive. In our case, we’ve chosen out removable USB drive. using the arrow forward key, choose ‘Proceed’ and press ENTER.

TestDisk mechanically detects the partition table sort. For non-partitioned disks like USB drives, a non-partitioned media type are detected. So, press ENTER.

Your removable drive’s partition table are listed as indicated. At the lowestchoose ‘Undelete’
TestDisk scans your drive for undeleted files and highlights them in red.

To recover these files, you wish to pick them 1st. So, scroll down and sort a full colon (:) for every choiceyou may discover that every file is highlighted in green.

Now press SHIFT + C for capital ‘C’ to repeat the files. you may be prompted to pick out your most popular destination to save lots of the files. during this example, we’ve got chosen to save lots of the files within the ‘Public’ directory. Once you’ve got hand-picked your directory, press ENTER.

The modification dates of the target directory are displayed. you’ll be able to opt for any choice, and another time, press ENTER.

TestDisk will give notice you that the files are with success traced.

To confirm that the files are copied, head over to the destination directory and ensure that the files exist.
The recovered files square measure saved with root permissions and ownershipyou’ll be able to change the permissions with chown command.

To exit TestDisk, press ‘q’ repeatedly till your finally return to your bash shell.

Conclusion

That was an indication of how you’ll recover deleted files in UNIX/Linux using the TestDisk utility. just in case you’ve got a tough disk that you simply need to recover files from or cannot boot entirely, merely take away the magnetic diskand fix it to a USB adapter and plug it in a very UNIX/Linux system with TestDisk put inwe tend to hope you’ve got found this guide helpfulwe glance forward to having your feedback.