久久精品五月,日韩不卡视频在线观看,国产精品videossex久久发布 ,久久av综合

站長資訊網(wǎng)
最全最豐富的資訊網(wǎng)站

linux刪除的文件如何恢復(fù)?

linux刪除的文件如何恢復(fù)?下面本篇文章給大家介紹一下恢復(fù)Linux刪除文件的方法。有一定的參考價值,有需要的朋友可以參考一下,希望對大家有所幫助。

linux刪除的文件如何恢復(fù)?

linux不像windows有個回收站,使用rm -rf *基本上文件是找不回來的。

那么問題來了:

對于linux下誤刪的文件,我們是否真的無法通過軟件進行恢復(fù)呢?

答案當然是否定的,對于誤刪的文件,我們還是能通過軟件恢復(fù)過來的。對于誤刪文件還原可以分為兩種情況:

  • 一種是刪除以后在進程存在刪除信息

  • 一種是刪除以后進程都找不到,只有借助于工具還原。

接下來以例子分別解說下兩種不同的誤刪還原方式:

誤刪除文件進程還在的情況:

這種一般是有活動的進程存在持續(xù)標準輸入或輸出,到時文件被刪除后,進程PID依舊存在。這也是有些服務(wù)器刪除一些文件但是磁盤不釋放的原因。

打開一個終端對一個測試文件做cat追加操作:

[root@docking ~]# echo "This is DeleteFile test." > deletefile.txt [root@docking ~]# ls deletefile.txt [root@docking ~]# cat >> deletefile.txt  Add SomeLine into deletefile for fun.

打開另外一個終端查看這個文件可以清楚看到內(nèi)容:

[root@docking ~]# ls deletefile.txt [root@docking ~]# cat deletefile.txt  This is DeleteFile test. Add SomeLine into deletefile for fun.

此時,刪除文件rm -f deletefile.txt

[root@docking ~]# rm -f deletefile.txt  [root@docking ~]# ls #命令查看這個目錄,文件已經(jīng)不存在了,那么現(xiàn)在我們將其恢復(fù)出來。
  • lsof查看刪除的文件進程是否還存在。

  • 如沒有安裝請自行yum install lsof或者apt-get install lsof

1、類似這種情況,我們可以先lsof查看刪除的文件 是否還在

[root@docking ~]# lsof | grep deletefile cat       21796          root    1w      REG              253,1        63     138860 /root/deletefile.txt (deleted)

2、恢復(fù)cp /proc/pid/fd/1 /指定目錄/文件名

進入 進程目錄,一般是進入/proc/pid/fd/,針對當前情況:

[root@docking ~]# cd /proc/21796/fd [root@docking fd]# ll 總用量 0 lrwx------ 1 root root 64 1月  18 22:21 0 -> /dev/pts/0 l-wx------ 1 root root 64 1月  18 22:21 1 -> /root/deletefile.txt (deleted) lrwx------ 1 root root 64 1月  18 22:21 2 -> /dev/pts/0

恢復(fù)操作:

[root@docking fd]# cp 1 ~/deletefile.txt.backup [root@docking fd]# cat ~/deletefile.txt.backup  This is DeleteFile test. Add SomeLine into deletefile for fun.

3、恢復(fù)完成。

誤刪除的文件進程已經(jīng)不存在,借助于工具還原

準備一些文件目錄

#準備一份掛載的盤 mkdir backuptest cd backuptest mkdir deletetest mkdir deletetest/innerfolder echo "Delete a folder test." > deletetest/innerfolder/deletefile.txt   echo "tcpdump:x:172:72::/:/sbin/nologin" > tmppasswd

最后準備的目錄結(jié)構(gòu)如下:

taroballs@taroballs-PC:/media/taroballs/taroballs/backuptest$ cd .. taroballs@taroballs-PC:/media/taroballs/taroballs$ tree backuptest/ backuptest/ ├── deletetest │   └── innerfolder │       └── deletefile.txt └── tmppasswd  2 directories, 2 files

現(xiàn)在開始刪除該目錄rm -rf backuptest/

taroballs@taroballs-PC:/media/taroballs/taroballs$ rm -rf backuptest/ taroballs@taroballs-PC:/media/taroballs/taroballs$  ls  -l 總用量 0

這種情況一般是沒有守護進行或者后臺進程對其持續(xù)輸入,所以刪除就真的刪除了。lsof也看不到,故需要采用工具進行恢復(fù)。

現(xiàn)在開始進行誤刪除文件的恢復(fù)。

我們采用的工具是extundelete第三方工具。恢復(fù)步驟以及注意事項如下:

  • 停止對當前分區(qū)做任何操作,防止inode被覆蓋。inode被覆蓋基本就告別恢復(fù)了。

  • 夸張一點講,比如停止所在分區(qū)的服務(wù),卸載目錄所在的設(shè)備,有必要的情況下都可以斷網(wǎng)。

  • 通過dd命令對 當前分區(qū)進行備份,防止第三方軟件恢復(fù)失敗導(dǎo)致數(shù)據(jù)丟失。

  • 適合數(shù)據(jù)非常重要的情況,這里是例子,所以就沒有備份,如備份可以考慮如下方式:dd if=/path/filename of=/dev/vdc1

  • 通過umount命令,對當前設(shè)備分區(qū)卸載?;蛘遞user 命令umount /dev/vdb1

  • 如果提示設(shè)備busy,可以用fuser命令強制卸載:fuser -m -v -i -k ./

  • 下載第三方工具extundelete安裝,搜索誤刪除的文件進行還原

extundelete工具安裝

extundelete下載地址:http://extundelete.sourceforge.net/

wget https://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2

解壓該文件tar jxvf extundelete-0.2.4.tar.bz2

若報這種錯誤

[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2  tar (child): bzip2:無法 exec: 沒有那個文件或目錄 tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now

則使用yum -y install bzip2進行解決

[root@docking ~]# tar jxvf extundelete-0.2.4.tar.bz2  extundelete-0.2.4/ extundelete-0.2.4/acinclude.m4 extundelete-0.2.4/missing extundelete-0.2.4/autogen.sh extundelete-0.2.4/aclocal.m4 extundelete-0.2.4/configure extundelete-0.2.4/LICENSE extundelete-0.2.4/README ...................................................
cd  extundelete-0.2.4 ./configure

若這步驟報錯

[root@docking extundelete-0.2.4]# ./configure  Configuring extundelete 0.2.4 configure: error: in `/root/extundelete-0.2.4': configure: error: C++ compiler cannot create executables See `config.log' for more details

則使用yum -y install gcc-c++解決.

若執(zhí)行上一步仍然報錯,

[root@docking extundelete-0.2.4]# ./configure  Configuring extundelete 0.2.4 configure: error: Can't find ext2fs library

則使用yum -y install e2fsprogs e2fsprogs-devel來解決。
#Ubuntu的解決辦法為sudo apt-get install e2fslibs-dev e2fslibs-dev

不出意外的話到這里應(yīng)該configure能夠順利完成.

[root@docking extundelete-0.2.4]# ./configure  Configuring extundelete 0.2.4 Writing generated files to disk [root@docking extundelete-0.2.4]#

最后make然后 make install

[root@docking extundelete-0.2.4]# make make -s all-recursive Making all in src extundelete.cc: 在函數(shù)‘ext2_ino_t find_inode(ext2_filsys, ext2_filsys, ext2_inode*, std::string, int)’中: extundelete.cc:1272:29: 警告:在 {} 內(nèi)將‘search_flags’從‘int’轉(zhuǎn)換為較窄的類型‘ext2_ino_t {aka unsigned int}’ [-Wnarrowing]     buf, match_name2, priv, 0};                              ^ [root@docking extundelete-0.2.4]# make install Making install in src   /usr/bin/install -c extundelete '/usr/local/bin'

extundelete安裝完成.

掃描誤刪除的文件:

使用df -lh查看掛載:

taroballs@taroballs-PC:~$ df -lh 文件系統(tǒng)        容量  已用  可用 已用% 掛載點 udev            1.9G     0  1.9G    0% /dev tmpfs           387M  1.8M  385M    1% /run /dev/sda2        92G   61G   26G   71% / tmpfs           1.9G   49M  1.9G    3% /dev/shm tmpfs           5.0M  4.0K  5.0M    1% /run/lock tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup /dev/sda3       104G   56G   44G   57% /home tmpfs           387M   40K  387M    1% /run/user/1000 /dev/sda4        70G   20G   47G   30% /media/taroballs/d8423f8c-d687-4c03-a7c8-06a7fb57f96d /dev/sdb1       6.8G  4.1G  2.8G   60% /media/taroballs/taroballs /dev/sr0        4.0G  4.0G     0  100% /media/taroballs/2018-01-16-12-36-00-00 taroballs@taroballs-PC:~$ cd /media/taroballs/taroballs/ taroballs@taroballs-PC:/media/taroballs/taroballs$

可以看到,我們的目錄/media/taroballs/taroballs

掛載到/dev/sdb1 這個文件系統(tǒng)中.

umount我們的掛載盤

比如:

taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1 /dev/sdb1       6.8G  4.1G  2.8G   60% /media/taroballs/taroballs

umount這個目錄

taroballs@taroballs-PC:~$ umount /media/taroballs/taroballs taroballs@taroballs-PC:~$ df -lh | grep /dev/sdb1 taroballs@taroballs-PC:~$  #記得刪除一定要后umount哦,不然二次寫入誰也幫不了你呢。

通過inode節(jié)點恢復(fù)

taroballs@taroballs-PC:~$ mkdir recovertest taroballs@taroballs-PC:~$ cd recovertest/ taroballs@taroballs-PC:~/recovertest$

執(zhí)行恢復(fù)extundelete /dev/sdb1 --inode 2

taroballs@taroballs-PC:/media/taroballs/taroballs$ sudo extundelete /dev/sdb1 --inode 2 NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Group: 0 Contents of inode 2:   . .省略N行   File name                                       | Inode number | Deleted status .                                                 2 ..                                                2 deletetest                                        12             Deleted tmppasswd                                            14             Deleted

通過掃描發(fā)現(xiàn)了我們刪除的文件夾,現(xiàn)在執(zhí)行恢復(fù)操作。

(1)恢復(fù)單一文件tmppasswd

taroballs@taroballs-PC:~/recovertest$  extundelete /dev/sdb1 --restore-file passwd    NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Successfully restored file tmppasswd

恢復(fù)文件是放到了當前目錄RECOVERED_FILES。

查看恢復(fù)的文件:

taroballs@taroballs-PC:~/recovertest$ cat tmppasswd  tcpdump:x:172:72::/:/sbin/nologin

(2)恢復(fù)目錄deletetest

extundelete /dev/sdb1 --restore-directory  deletetest NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Searching for recoverable inodes in directory deletetest ...  5 recoverable inodes found. Looking through the directory structure for deleted files ...

(3)恢復(fù)所有

taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-all NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. Searching for recoverable inodes in directory / ...  5 recoverable inodes found. Looking through the directory structure for deleted files ...  0 recoverable inodes still lost.  taroballs@taroballs-PC:~/recovertest$ tree  backuptest/ ├── deletetest │   └── innerfolder │       └── deletefile.txt └── tmppasswd 2 directories, 2 files

(4)恢復(fù)指定inode

taroballs@taroballs-PC:~/recovertest$ extundelete /dev/sdb1 --restore-inode 14 NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 46 descriptors loaded. taroballs@taroballs-PC:~/recovertest$ cat file.14  tcpdump:x:172:72::/:/sbin/nologin #注意恢復(fù)inode的時候,恢復(fù) 出來的文件名和之前不一樣,需要單獨進行改名。

最后附上extundelete的用法:

$ extundelete --help Usage: extundelete [options] [--] device-file Options:   --version, -[vV]       Print version and exit successfully.   --help,                Print this help and exit successfully.   --superblock           Print contents of superblock in addition to the rest.                          If no action is specified then this option is implied.   --journal              Show content of journal.   --after dtime          Only process entries deleted on or after 'dtime'.   --before dtime         Only process entries deleted before 'dtime'.Actions:   --inode ino            Show info on inode 'ino'.   --block blk            Show info on block 'blk'.   --restore-inode ino[,ino,...]                          Restore the file(s) with known inode number 'ino'.                          The restored files are created in ./RECOVERED_FILES                         with their inode number as extension (ie, file.12345).   --restore-file 'path'  Will restore file 'path'. 'path' is relative to root                          of the partition and does not start with a '/'                          The restored file is created in the current                          directory as 'RECOVERED_FILES/path'.   --restore-files 'path' Will restore files which are listed in the file 'path'.                          Each filename should be in the same format as an option                          to --restore-file, and there should be one per line.   --restore-directory 'path'                          Will restore directory 'path'. 'path' is relative to the                          root directory of the file system.  The restored                          directory is created in the output directory as 'path'.   --restore-all          Attempts to restore everything.   -j journal             Reads an external journal from the named file.   -b blocknumber         Uses the backup superblock at blocknumber when opening                          the file system.   -B blocksize           Uses blocksize as the block size when opening the file                          system.  The number should be the number of bytes.   --log 0                Make the program silent.   --log filename         Logs all messages to filename.--log D1=0,D2=filename   Custom control of log messages with comma-separated    Examples below:       list of options.  Dn must be one of info, warn, or   --log info,error      error.  Omission of the '=name' results in messages   --log warn=0          with the specified level to be logged to the console.    --log error=filename  If the parameter is '=0', logging for the specified                          level will be turned off.  If the parameter is                          '=filename', messages with that level will be written                          to filename.    -o directory          Save the recovered files to the named directory.                          The restored files are created in a directory                          named 'RECOVERED_FILES/' by default.

推薦:《linux教程》

贊(0)
分享到: 更多 (0)
?
網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號
久久精品五月,日韩不卡视频在线观看,国产精品videossex久久发布 ,久久av综合
国产精品极品| 中文精品电影| 激情偷拍久久| 麻豆高清免费国产一区| 红桃视频欧美| 超碰成人av| 亚洲伊人精品酒店| 欧美亚洲国产精品久久| 黄色成人在线网址| 亚洲一区欧美二区| 亚洲97av| 久久精品一区二区国产| 日韩一区二区三免费高清在线观看 | 久久国产日韩| 亚洲免费专区| 国产精品麻豆成人av电影艾秋| 婷婷亚洲五月| 国产精品美女在线观看直播| 国内自拍视频一区二区三区| 综合欧美精品| 亚洲欧美高清| 麻豆视频一区二区| 宅男在线一区| 国产精品中文字幕制服诱惑| 久久国产中文字幕| 国产精品白丝久久av网站| 国产精品99在线观看| 91精品国产自产观看在线| 亚洲激情偷拍| 婷婷亚洲五月| 国产亚洲一级| 蜜臀av一区二区三区| 巨乳诱惑日韩免费av| 亚洲欧美日韩专区| 久久激情av| 国产精品久av福利在线观看| 国产婷婷精品| 成人日韩av| 久久99高清| 欧美综合精品| 欧美亚洲专区| 亚洲免费黄色| 一区二区三区四区日本视频| 国产麻豆一区| 免费在线观看精品| 日韩精品亚洲一区二区三区免费| 一区在线免费观看| 久久久久中文| 精品三级国产| 国产亚洲一级| 蜜臀av一区二区三区| 国产精品一区二区三区四区在线观看| 国产欧美日韩免费观看| 日韩精品五月天| 精品成av人一区二区三区| 久久爱www.| 国产精品专区免费| 免播放器亚洲一区| 麻豆高清免费国产一区| 中文一区一区三区高中清不卡免费| 国产专区一区| 国产精品天天看天天狠| 久久女人天堂| 久久电影tv| 欧美在线不卡| 亚洲视频二区| 国产精品亚洲欧美| 国产欧美一区二区精品久久久| 午夜精品福利影院| **爰片久久毛片| 免费一级欧美在线观看视频| 欧美精品国产| 久久精品女人| a天堂资源在线| 视频一区在线播放| 欧美日韩中文| 日韩综合在线| 天堂va欧美ⅴa亚洲va一国产| 中文字幕在线看片| 欧美日韩18| 国产亚洲午夜| 国产日韩欧美三区| 婷婷国产精品| 红桃视频亚洲| 福利一区和二区| 日韩影片在线观看| 欧美手机在线| 精品亚洲成人| 日韩极品在线观看| 偷拍精品精品一区二区三区| 欧美久久久网站| 天堂成人国产精品一区| 亚洲精品永久免费视频| 欧美日韩xxxx| 久久最新视频| 欧美日韩视频一区二区三区| 国产三级精品三级在线观看国产| 欧美日韩精品一区二区视频| 国产精品日韩精品中文字幕| 亚洲一区二区日韩| 日本vs亚洲vs韩国一区三区二区| 欧美日韩免费观看视频| 国产毛片一区二区三区| 亚洲欧美专区| av高清不卡| 国产亚洲字幕| 亚洲精品进入| 妖精视频成人观看www| 免费观看日韩电影| 国产精品宾馆| 国产粉嫩在线观看| 久久天堂av| 欧美理论视频| 亚洲二区三区不卡| 久久成人国产| 欧美中文字幕| 国产一区导航| 99久久99视频只有精品| 激情综合网五月| 免费在线播放第一区高清av| 日日夜夜免费精品视频| 首页国产欧美日韩丝袜| 欧美精品一区二区久久| 亚洲午夜一级| 久久一区二区三区电影| 婷婷激情一区| 日韩欧美在线中字| 亚洲精品永久免费视频| 久久久久久婷| 成人美女视频| 日韩成人精品一区二区三区 | 久久精品xxxxx| 久久午夜视频| 久久黄色影视| 国产激情一区| 精品国产一区二区三区2021| 免费一级欧美片在线观看网站 | 国产精品av一区二区| 日韩精品一二三四| 老司机精品视频在线播放| 日本国产精品| 欧美日韩国产一区二区在线观看| 欧美jjzz| 水蜜桃久久夜色精品一区的特点 | 欧美午夜网站| 欧美日韩亚洲一区在线观看| 日韩中文字幕视频网| 日韩成人一级| 国产精品a久久久久| 日本一区二区免费高清| 日韩欧美一区免费| 夜久久久久久| 天堂俺去俺来也www久久婷婷| 亚洲午夜免费| 日本不卡在线视频| 久久精品国产99国产精品| 日韩88av| 欧美91视频| 日韩精品免费一区二区夜夜嗨| 国产精品久久久久久av公交车| av资源中文在线天堂| 欧美在线亚洲综合一区| 日韩免费精品| 国产成人1区| 亚洲一本视频| 亚洲精品国产精品粉嫩| 国产精品高潮呻吟久久久久| 国产美女高潮在线| 亚洲精品国产偷自在线观看| 亚洲精品人人| 国产一区2区在线观看| 亚洲国产专区| 日韩一区二区三免费高清在线观看 | 在线亚洲一区| 欧美伊人久久| 亚洲四虎影院| 中文无码日韩欧| 国产一区二区三区四区大秀 | 久久久久91| 综合亚洲自拍| 精品国产日韩欧美精品国产欧美日韩一区二区三区 | 午夜在线一区二区| 国产精品视频一区二区三区四蜜臂| 狠狠久久伊人中文字幕| 99视频精品| 麻豆精品视频在线观看视频| 1000部精品久久久久久久久| 日韩av中文字幕一区二区| 日韩电影二区| 中文字幕日本一区| 日韩中文首页| 中文字幕一区二区精品区| 久久久久久一区二区| 99国产成+人+综合+亚洲欧美| 国产精品一区亚洲| 欧美日韩国产亚洲一区| 欧美.日韩.国产.一区.二区 | 日本va欧美va瓶| 欧美日一区二区| 国产日韩欧美三级|