Recovery of deleted Linux files
Restoring deleted files in Linux can be quite a difficult task, especially if special tools for safe data deletion were used. However, if the files were accidentally deleted or were in the trash (Trash), there are several methods and programs that can help restore data.
1. Using the "undelete" command: In some Linux distributions, there is an "undelete" utility that allows you to restore accidentally deleted files from the ext3/ext4 partition. Administrator rights (root) are required to use this command. Example: `sudo undelete /dev/sdaX` - where `/dev/sdaX` is the section containing the lost file.
2. PhotoRec: This is a free cross-platform program for data recovery from a hard disk and other information carriers running Unix/Linux/Windows/MacOS X/BSD/Solaris/FreBSD/OpenBSD/QNX/i386/Darwin operating systems.
Install it through the package manager of your distribution:
“`
sudo apt-get install testdisk
“`
Connect a flash drive or HDD from where you would like to search:
“`
sudo photorec /dev/sdX
“`
3. Foremost: This is another free data recovery utility that can be used on Linux. It specializes in searching and extracting various types of files (images, documents, audio, etc.) from a damaged or deleted drive.
Install the program:
“`bash
sudo apt-get install foremost
“`
Start the scan by specifying the path to the block device:
“`bash
sudo foremost -i /dev/sda1 -o output/
“`
Where `/dev/sda1` is your partition.
4. TestDisk: Another powerful tool for recovering lost data under Linux/Windows/MacOS X/BSD/Solaris/FreBSD/OpenBSD/QNX/i386/Darwin
We install it through the package manager of your distribution
``bash
sudo apt-get install testdisk
“`
Then we run the `testdisk` command, having selected the necessary information storage.
It is important to remember the following