linux中通过lsof恢复删除的文件,前题是fd被占用。
http://www.serverwatch.com/tutorials/article.php/3822816/Recovering-Deleted-Files-With-lsof.htm
One of the more neat things you can do with the versatile utility lsof is use it to recover a file you've just accidentally deleted.
Tip of the Trade: Accidentally deleted files are easily recovered with lsof.
A file in Linux is a pointer to an inode, which contains the file data (permissions, owner and where its actual content lives on the disk). Deleting the file removes the link, but not the inode itself – if another process has it open, the inode isn't released for writing until that process is done with it.
|
Recent Tips
» The Various bash Prompts » Disk Encryption With TrueCrypt » Protecting Your Root Password Read All Tips of the Trade |
To try this out, create a test text file, save it and then type less
test.txt. Open another terminal window, and type rm
testing.txt. If you try ls testing.txt you'll get an
error message. But! less still has a reference to the file. So:
> lsof | grep testing.txt |
The important columns are the second one, which gives you the PID of the process that has the file open (4607), and the fourth one, which gives you the file descriptor (4). Now, we go look in /proc, where there will still be a reference to the inode, from which you can copy the file back out:
> ls -l /proc/4607/fd/4 |
Note: don't use the -a flag with cp, as this will copy the (broken) symbolic link, rather than the actual file contents.
Now check the file to make sure you've got what you think you have, and you're done!
linux中通过lsof恢复删除的文件,前题是fd被占用。的更多相关文章
- Linux中.a,.la,.o,.so文件的意义和编程实现
Linux中.a,.la,.o,.so文件的意义和编程实现 Linux下文件的类型是不依赖于其后缀名的,但一般来讲: .o,是目标文件,相当于windows中的.obj文件 ...
- 诠释Linux中『一切都是文件』概念和相应的文件类型
导读 在 Unix 和它衍生的比如 Linux 系统中,一切都可以看做文件.虽然它仅仅只是一个泛泛的概念,但这是事实.如果有不是文件的,那它一定是正运行的进程. 要理解这点,可以举个例子,您的根目录( ...
- linux中tar 打包指定路径文件
linux中tar打包指定路径文件www.111cn.net 编辑:yahoo 来源:转载在linux系统中打包与解压文件我都可以使用tar命令来解决,只要使用不同的参数就可以实现不同的需要了,下面来 ...
- 【转】Linux 中清空或删除大文件内容的五种方法(truncate 命令清空文件)
原文: http://www.jb51.net/article/100462.htm truncate -s 0 access.log -------------------------------- ...
- linux中c表示字符设备文件符号
linux中c表示字符设备文件,b表示块设备文件,l表示符号链接文件,r表示可读权限,w表示可写权限.linux文件属性解读:文件类型:-:普通文件 (f)d:目录文件b:块设备文件 (block)c ...
- linux 中的页缓存和文件 IO
本文所述是针对 linux 引入了虚拟内存管理机制以后所涉及的知识点.linux 中页缓存的本质就是对于磁盘中的部分数据在内存中保留一定的副本,使得应用程序能够快速的读取到磁盘中相应的数据,并实现不同 ...
- linux中touch命令参数修改文件的时间戳(转)
linux中touch命令参数不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件,以下是linux中touch命令参数的使用方法: touch [-acm][-r ...
- linux中touch命令参数修改文件的时间戳(转载)
转自:http://os.51cto.com/art/200908/144237.htm linux中touch命令参数不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存 ...
- Linux基础教程 linux中使用find命令搜索文件常用方法记录
find是linux非常强大的搜索命令,通过man find查看find手册,可以发现find的说明一屏接一屏,估计要看完也得花不少时间.兄弟连Linux培训 小编总结了下,整理出find常用的使用方 ...
随机推荐
- [javascript]XMLHttpRequest GET/SET HTTP头与改变HTTP METHOD示例代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- jQuery-lazyload参数
1.placeholder placeholder:'图片地址',用图片提前占据将要加载的图片的位置. 2.effect effect:‘fadeIn’ 表示用何种效果载入,eg:show()直接加载 ...
- Confluence 6 MySQL 问题解决
如果 Confluence 提示没有 class 文件,你可能将你的 JDBC 驱动放置到了错误的文件夹. 如果你收到了下面的错误信息,请确认 confluenceuser 用户已经具有了所有需求的数 ...
- Confluence 6 CSS 编辑快速入门
希望编辑空间的 CSS 样式表: 进入空间后,然后从边栏的底部选择 空间工具(Space tools) > 外观和感觉(Look and Feel) . 然后选择 样式表(Stylesheet) ...
- vue三大框架
vue 前端三大新框架: Angular.js------Google研发 缺点: 学习成本高.最早研发 严谨 React.js facebook.com (脸书)自主研发 开源 j ...
- 《剑指offer》 链表中倒数第k个节点
本题来自<剑指offer> 链表中倒数第k个节点 题目: 输入一个链表,输出该链表中倒数第k个结点. 思路: 倒数第k个节点,而且只能访问一遍链表,定义两个节点,两者之间相差k个距离,遍历 ...
- wireless Penetration Testing & Honeypot and Mis-Association attacks
重新记一遍 ,在捕获握手数据包的时候不容易获取,所以使用ARP请求.使用自己的无线网卡的地址发送请求,会容易使得无线开启端掉线,迫使重新连接. 1.使用命令 aireplay-ng -3 -b a ...
- css中border画三角形
<!doctype html><html lang="en"> <head> <meta charset="UTF-8&quo ...
- ShadingJdbc学习
可参考:https://blog.csdn.net/jadebai/article/details/86716082 https://blog.csdn.net/jadebai/article/det ...
- truncate table时存在外键约束的解决办法
以前在使用truncate命令时遇到表存在外键引用时无法执行命令的情况都是用delete来代替,今天又遇到这个问题,于是在网上搜了一把,可以通过如下方式解决: 1.基本思路:先关闭mysql的外键约束 ...