在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++代码编译,后续再看有没有其它影响。