How to install and use Testdisk in Ubuntu?

If you are in a situation where you have accidentally deleted some files on your system and don’t know how to get them back well you can try data recovery tools available for Linux.

Testdisk is a free and open-source command-based data recovery tool. It is mainly used to retrieve damaged partitions and make a non-bootable disk bootable again which is caused by faulty software or human error.

In this article, I will discuss how to install and use the Testdisk utility in Ubuntu.

Features of Testdisk utility

The key features of Testdisk are –

  • It can be used to get complete information about a corrupted disk
  • Compatible with various operating systems including Linux, Windows, macOS, etc
  • Able to recover deleted partitions
  • Create partition backup for EFI GPT partitions
  • Rebuilds partition table and rewrites corrupted MBR

How to install Testdisk in Ubuntu

Before you install Testdisk in your system make sure to update the package list and upgrade packages to their latest version.

Use the following command to update the package list –

sudo apt update & sudo apt upgrade -y

Now use the given command to install Testdisk in your system –

sudo apt install testdisk -y

You can verify the installation of Testdisk by using –

testdisk -v

This will display the current version of the Testdisk utility installed on your system.

testdisk version

How to recover deleted files in Ubuntu

Now Testdisk has been installed on your system you can run it to recover deleted files and partitions on your system.

First, use the following command to list all disk and partitions on your system –

df -h

list disks

Next, run the Testdisk utility by using –

tesdisk

testdisk

Press the Enter key and use the arrow key to navigate and select the disk or partition where you want to recover data. Navigate to Proceed and then press the Enter.

select disk to recover

Next, select the partition table type on the disk and press Enter.

select partition type

Analyze the current partition structure for the lost partitions –

analyse

Next, you can choose to perform a quick search or deeper search for deleted files on the disk –

quick search

This will start and take some time to analyze disk or partition –

analyze disk

Once the analysis is completed you will be asked to choose a partition, select one of them, and press this will display the content of that partition.

list content

Press c to copy the selected file to a different location on your system. To exit from the utility you can press q.

For more usage, you can read its official documentation.

Conclusion

You have successfully installed and used Testdisk for recovering files on your system. Now if you have a query then write us in the comments below.

Leave a Comment