Loss of data is one of the most stressful and painful experiences a user can have. The fear of never being able to recover valuable data once it has been erased or lost causes worry and leaves consumers powerless. But don’t take tension; there are some software and ways available that help you recover deleted files on your Linux workstations. We will provide a better solution to this data loss problem in this Article on Ubuntu (Linux Operating System).
The simpler way is to recover it from the “Trash” directory using a Graphical User Interface. Another way is by installing Test Disk software through the Command Line Interface.
Recover Deleted Data on a Linux System
Below two ways are provided to recover data from Ubuntu. You can follow any of the approaches which are appropriate for you.
Method1: Recover Deleted Data on Ubuntu using Trash directory
Whenever we delete some data on Ubuntu (Linux OS), a copy of that deleted data is saved to the trash folder, so that if we want to recover the data, we can recover it from the Trash directory. Now follow the procedure below.
Step 1: Open Trash directory
Click on the “Trash” directory.
Step 2: Restore the file
Now select the file from the trash directory which you want to recover and click on the “Restore” button, below I am recovering the “Linux” folder.
Now the restored file will be removed from the Trash director and stored back from where it is deleted.
Method 2: Recover Deleted Data on Ubuntu using Test Disk
Test Disk is one of the useful approaches to the data loss problem. Test Disk is a free and sophisticated data recovery application that rebuilds and restores boot partitions and updates partition tables, among other things. It recovers deleted data from a variety of file systems, including FAT, exFAT, ext3, ext4, and NTFS, to name a few, and copies them to a new spot. One of the characteristics that distinguish Test Disk from other data recovery applications is that it is a Command-Line data retrieval tool.
Step 1: Update Packages
Before installing any software firstly, you need to update your package list, run the below-mentioned command to update all packages.
$ sudo apt update
Step 2: Installation of Test Disk Software
Now run the given below command to install the Test Disk recovery software.
$ sudo apt install testdisk
Step 3: Check installation
Write the given below command on the terminal to check that the Test Disk is successfully installed by checking its version.
$ testdisk --version
Step 4: Recover file using Test Disk
First, open the Test Disk file by the below-mentioned command:
$ sudo testdisk
Now from arrow keys move to the “Create” option and press Enter.
Now I want to recover a file from an external USB device “Kingston DT 101 G2” connected to my virtual machine so by arrow keys move down to it and then from down options move to “proceed” option and press Enter.
Now move to the “None” option for external devices.
Now the “FAT32” partition is available. Move to the partition and from the bottom move to the “Undeleted” option and press Enter to see all deleted and undeleted files and recover the deleted file.
The files in “red color” are deleted files that can be recovered. I want to recover “Linux” and I will move to that file and then press “c” to copy the deleted file.
Now select the destination where you want to copy the file and press “C” after selecting the correct destination.
Now the file is copied successfully.
Data loss is a major problem that causes a lot of stress but there are many recovery tools that help to recover lost data. In this article, we discussed the recovery methods of deleted data in Ubuntu (Linux OS). There are two ways; one is to recover data from the Trash directory and the other is through Test Disk software, which is open source software and helpful in recovering data from external mediums also. If you lost some valuable data and want to recover the data on Ubuntu then don’t worry, the solution is provided in this article.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.