Ubuntu 文件误删除恢复方法之任务挂起时恢复

10 篇文章 0 订阅

Linux 任务挂起数据被误删除时,可在/proc/任务PID/fd/下进行恢复

操作步骤如下:

john@u:~$ ls --help >ls.txt #创建一个测试文本
john@u:~$ ls
ls.txt  my_backup  shell  test
john@u:~$ more ls.txt #进行分页查看,翻下一页时 Ctrl+Z 退出
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
--More--(20%)
[1]+  Stopped                 more ls.txt
john@u:~$ jobs #查看后台运行任务
[1]+  Stopped                 more ls.txt
john@u:~$ rm ls.txt #删除测试文件
john@u:~$ ls
my_backup  shell  test
john@u:~$  ps aux | grep ls.txt
john      1161  0.0  0.3   3900   836 pts/0    T    15:50   0:00 more ls.txt
john@u:~$ ls -l /proc/1161/fd/ #根据 ps aux 显示内容得知 ls.txt 被 pid 1161 占用
total 0
lrwx------ 1 john john 64 Nov  6 15:55 0 -> /dev/pts/0
lrwx------ 1 john john 64 Nov  6 15:55 1 -> /dev/pts/0
lrwx------ 1 john john 64 Nov  6 15:52 2 -> /dev/pts/0
lr-x------ 1 john john 64 Nov  6 15:55 3 -> /home/john/ls.txt (deleted)
john@u:~$ cp /proc/1161/fd/3 ~/ls.txt.saved #将文件复制到 ~/目录重命名保存即可。
john@u:~$ ls
ls.txt.saved  my_backup  shell  test

参考文章: http://www.jb51.net/LINUXjishu/64736.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值