1. 程式人生 > >linux 檔案恢復

linux 檔案恢復

一、刪除檔案後(程序還存在)

[[email protected]]#echo 'hello  linux' > zhang.txt
[[email protected]]#echo 'delete'  >>zhang.txt 
[[email protected]]#cat zhang.txt 
hello  linux
delete
#模擬程序佔用該檔案
[[email protected]]#cat >> zhang.txt 


#刪除檔案
[[email protected]]#rm -f zhang.txt 
#檢視刪除的檔案
[
[email protected]
]#lsof |grep deleted cat 25558 root 1w REG 8,2 21 69197603 /del/zhang.txt (deleted) #檔案恢復 [[email protected]]#ll /proc/25558/fd/1 l-wx------ 1 root root 64 12月 6 09:57 /proc/25558/fd/1 -> /del/zhang.txt (deleted) #開始恢復(25558是對應的程序pid號) [
[email protected]
]#cp /proc/25558/fd/1 /del/ [[email protected]]#cat /del/1 hello linux delete