Linux避免用rm误删文件 - 遗失的记忆 - 博客大巴

Linux避免用rm误删文件 - 遗失的记忆 - 博客大巴

Linux避免用rm误删文件

日期:2010-12-11 | 分类:Linux使用

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://freakrobot.blogbus.com/logs/88281920.html

因为大部分的的linux发型套件已经采用了ext3/4文件系统,又因为rm命令删除的文件是不进垃圾箱的,所以用rm误删的文件一般是不能恢复的。

Q: How can I recover (undelete) deleted files from my ext3 partition?

Actually, you can't! This is what one of the developers, Andreas Dilger, said about it:

In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as "deleted" and leaves the block pointers alone.

因此我们要尽量避免文件被误删,我们创建一个新的命令del脚本来删除文件,将下面脚本存储在/usr/bin下,以后都用它来删除文件:

#!/bin/bash
mkdir~/.Trash &> /dev/null
while [ ! -z "$1" ]; do
    mv "$1" ~/.Trash/
    shift
done

 

posted on 2013-04-23 16:43  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2013/04/23/3038153.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值