博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux避免用rm误删文件 - 遗失的记忆 - 博客大巴
阅读量:7025 次
发布时间:2019-06-28

本文共 716 字,大约阅读时间需要 2 分钟。

Linux避免用rm误删文件

日期:2010-12-11 | 分类:

:转载时请以超链接形式标明文章原始出处和作者信息及

因为大部分的的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/bashmkdir~/.Trash &> /dev/nullwhile [ ! -z "$1" ]; do    mv "$1" ~/.Trash/    shiftdone

 

你可能感兴趣的文章
十八般武艺之Nginx踩坑总结
查看>>
为什么有人说组装机质量不好
查看>>
本地自旋锁与信号量/多服务台自旋队列-spin wait风格的信号量
查看>>
理想是自欺欺人的好东西
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
3.1 mysql客户端工具
查看>>
Ubuntu 14.04安装强大下载器uGet
查看>>
我的友情链接
查看>>
MySQL主从复制之主库宕机处理;
查看>>
Centos 搭建 zookeeper
查看>>
ASM学习笔记
查看>>
最新XtraBackup安装
查看>>
1、取得/etiantian文件的权限对应的数字(考试题答案系列)
查看>>
持续交付:发布可靠软件的系统方法
查看>>
varnish缓存实现动静分离
查看>>
安装numpy、scipy、matplotlib
查看>>
子网划分
查看>>
C# 获取当前ip
查看>>
linux下phpMyAdmin提示缺少mysqli扩展的解决方法
查看>>