When you delete the data stored on your Linux computer, the files are moved to the Trash folder, from where you can restore those deleted files within a specific time. It means that if you haven't saved any other file on the storage location of the deleted file or have not overwritten the storage space, you can easily recover the files. Follow the below steps to recover your deleted files on a Linux computer.
See that you do not copy or write or move any data files on the system.
Do not immediately install or run any recovery software on the computer.
Make sure to shut down the system once the file is deleted.
You need reliable software like TestDisk, PhotoRec, Extundelete, etc., for data recovery.
Read the following steps for Linux file recovery using TestDisk.
Open a web browser and visit the official TestDisk website.
Download the recovery tool compatible with your Linux operating system.
Once the TestDisk tool is downloaded on the system, install it. For that, open the terminal window and run the below command line.
sudo apt install testdisk
Once the installation has been completed, type the command testdisk and press Enter to run the tool on the system.
Carefully read the texts and guidelines that appear on the Terminal.
See that you can use the navigation keys to move and Enter key to select an option.
If the tool asks you to create a log file, go on to create a new log file.
Following that, the drive's name will appear at the bottom of the window.
Sometimes the drive name may not appear. In such a case, enter Sudo, type the password, and press Enter.
Once the tool displays the drives on the system, navigate to the drive in which you have to recover the file and press Enter.
After that, choose a partition table type and then select Advanced for more recovery options.
Select the Undelete option. Now the tool will start to scan the drive for deleted files.
Once the scan is done, a list of deleted files will appear in the window. Select the file you wish to recover and save it on your Linux computer.