Linux 系統并沒有像 Windows 那樣明顯的“回收站”功能,但刪除的文件仍然有可能被恢復。以下是幾種在 Linux 中恢復誤刪文件的方法:
extundelete
命令extundelete
是一個專門用于恢復 ext3 和 ext4 分區中刪除文件的工具。它利用文件系統的日志信息來嘗試恢復文件。
安裝 extundelete:
yum install extundelete
apt-get install extundelete
恢復文件:
extundelete /dev/vdb1 --restore-directory /path/to/directory
extundelete /dev/vdb1 --restore-file /path/to/file
extundelete /dev/vdb1 --restore-all
lsof
命令lsof
命令可以列出被進程打開的文件信息,有時候即使文件被刪除,只要進程仍在使用該文件,就可以通過 lsof
來恢復。
恢復文件:
lsof | grep deleted
然后根據輸出的進程 ID 和文件描述符信息,手動恢復文件。
除了 extundelete
,還有其他一些數據恢復工具可以嘗試,例如 foremost
、testdisk
、photorec
等。
使用 foremost 恢復文件:
foremost -t png -i /dev/sdb1
使用 testdisk 恢復分區:
testdisk
請注意,數據恢復是一個復雜的過程,具體方法可能會因情況而異。在進行任何恢復操作之前,請確保已經備份了所有重要數據,并盡可能減少對存儲設備的其他操作,以降低數據被覆蓋的風險。如果不確定如何操作,建議尋求專業人士的幫助。