在Ubuntu下編譯dlib後通過make install
安裝到/usr/local/,後期卸載時使用OpenCV的方法對*dlib*
進行搜索刪除,但因此誤刪的一些系統文件,如stdlib.h相關(其它文件如threadlib不知道有沒有什麼影響…),導致無法編譯c++代碼,因此在網上查找如何恢復Ubuntu下誤刪的文件。參考鏈接:
Ubuntu恢復被刪除的文件
Ubuntu誤刪/usr/include解決辦法
extundelete工具
extundelete工具可以對指定分區、指定時間段進行檢索恢復,恢復文件會放到當前目錄下的RECOVERED_FILES
文件夾中,操作流程爲:
# 安裝
sudo apt-get install extundelete
# 確定誤刪操作前的時間,並獲取dtime
date -d "2014-06-01 23:02:00" +%s # 1401634920
# 確定誤刪目錄的掛載點
df -h /usr # 假設/dev/sda4,/usr即誤刪操作的目錄,可以替換爲其它目錄
# 嘗試恢復
sudo extundelete /dev/sda4 --after 1401632880 --restore-all
'''
Only show and process deleted entries if they are deleted on or after 1401632880 and before 9223372036854775807
...
Would you like to continue? (y/n)
輸入y回車
Loading filesystem metadata ...
...
Restored inode 2883641 to file RECOVERED_FILES/xxx
表明恢復成功
No files were undelete
表明未檢測到刪除的文件,恢復失敗
Block bitmap checksum does not match bitmap when trying to examine filesystem
貌似沒有解決辦法
https://unix.stackexchange.com/questions/454536/extundelete-how-to-solve-block-bitmap-checksum-does-not-match-bitmap-when-try
'''
最後通過該方法沒有查找到誤刪文件。
dlocate工具
該方法目前測試能恢復/usr/include中的文件,但其它位置的通過修改路徑貌似沒恢復,如我在別的電腦上查找到的threadlib。操作流程:
# 安裝
sudo apt-get install dlocate
# 列出文件(我列出的好像都是當前存在的)
dlocate --package-only /usr/include
# 重裝文件
sudo apt-get install --reinstall $(dlocate --package-only /usr/include)
通過該方法成功找回stdlib相關文件,並完成c++代碼編譯,後續再看有沒有其它影響。