The lost or deleted files will be saved in the Trash folder. If you cannot find the deleted files in Trash, you can recover them using a third-party data recovery software. The instructions to recover deleted files in Ubuntu through Testdisk utility are mentioned below.
Step 1 - Installing The TestDisk Utility
Hold the Ctrl, alt, and T keys at the same time to open the Terminal window on your Ubuntu computer.
Type ‘$ sudo apt-get install testdisk’ without the quotes and press Enter.
Enter the system password.
This will install the Testdisk utility on the Ubuntu computer.
To check if the utility is installed or not, enter ‘$ testdisk --version’ or $ ‘testdisk -v’ without the single quotes.
You will also see the version of the installed software in the Terminal window.
Step 2 - Run The TestDisk Utility
Enter the ‘$ testdisk’ command in the Terminal window.
The description of the installed TestDisk utility will be shown in the Terminal window.
Also, it displays the following options.
To create a testdisk.log file, select the Create option using the arrow key. This will recover deleted files in Ubuntu through Testdisk.
Step 3 - Selecting Your Drive
After creating the log file, the Terminal window shows a list of storage drives that are attached to the Ubuntu computer.
Select the drive where you have lost the files.
Use the right or left arrow key to select the Proceed option.
If you do not see your drive, select the Sudo option and type the system password.
Note: Some of the drives might not be shown due to security permissions.
Now, you will see all the drives in the Terminal window.
Step 4 - Selecting partition of your drive
Once you have selected the drive, its partition table type will be displayed in the Terminal window.
The TestDisk utility highlights the correct partition type automatically.
Press the Enter key to continue to recover deleted files in Ubuntu through Testdisk.
Step 5 - Advanced option
To recover deleted files, select the Advanced option and press the Enter key on the keyboard.
Step 6 - Multiple partitions
If you have multiple partitions in the selected drive, a list of partition lists will have appeared in the Terminal window.
Select the partition followed by the directory where you have lost the files.
The deleted files are shown in red.
Step 7 - Restoring the lost files
Copy the highlighted files, mention the location to save the restored files, and select the C key.
The TestDisk utility will save the selected files in the specified location.
Step 8 - Removing TestDisk
If you want to delete the TestDisk utility from Ubuntu, enter the ‘$ sudo apt-get remove testdisk’ command in the Terminal window. If you need a remote assistance to recover deleted files in Ubuntu through Testdisk, click the call button.