在Debian系统中,如果你想恢复被删除或丢失的文件,可以使用一些数据恢复工具。以下是一些常用的恢复方法:
foremost
恢复文件foremost
是一个基于文件头和尾部信息以及文件的内建数据结构恢复文件的命令行工具。它支持多种文件类型,包括图片、文档、音频等。
操作步骤:
foremost
:sudo apt install foremost # 在基于 Debian 的系统(如 Ubuntu)中
echo "this is an important file" > important.txt
sudo rm /home/user/documents/important.txt
sudo foremost -t all -i /dev/sda1 -o /tmp/recovered_files
ls /tmp/recovered_files
extundelete
恢复文件extundelete
是一个专门用于恢复 ext3 和 ext4 文件系统中已删除文件的工具。它通过扫描文件系统的数据结构,尝试找回被删除的文件。
操作步骤:
sudo apt install e2fsprogs-devel # 在基于 Debian 的系统(如 Ubuntu)中
extundelete
:wget https://src.fedoraproject.org/repo/pkgs/extundelete/extundelete-0.2.4.tar.bz2/77e626ad31433680c0a222069295d2ca/extundelete-0.2.4.tar.bz2
tar -jxvf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4
./configure --prefix=/usr/local/extundelete && make && sudo make install
echo "this is an important file" > important.txt
sudo rm /home/user/documents/important.txt
sudo /usr/local/extundelete/bin/extundelete /dev/sda1 --restore-all
ls RECOVERED_FILES
请注意,数据恢复的成功率并不是100%,尤其是在数据被覆盖或删除后。因此,为了避免数据丢失,建议定期备份重要数据。