一招教你预防rm -rf误删文件,避免删库跑路的悲剧

不要以为自己不会犯这么低级的错误,有时候意外就是很突然.一个手抖,多打一个空格,亦或者在很微妙的位置提前敲你TAB补全,都有可能误删其他重要文件,甚至把整个系统都给删掉.

以下方法仅供抛砖引玉

偶然看到一个比较好用的工具Trash-Cli。一个类似垃圾桶的机制,可以恢复文件。试了一下,感觉还行

(1)下载安装:

https://github.com/andreafrancia/trash-cli

[root@bogon ~]# yum install git -y      #安装git
[root@bogon ~]#git clone https://github.com/andreafrancia/trash-cli.git  #git克隆岛本地
[root@bogon ~]#cd trash-cli
[root@bogon trash-cli]#sudo python setup.py install  #开始安装

(2)使用方法:

[root@bogon ~]# trash  #可以看到有不少命令。trash-empty清空垃圾桶 trash-list查看垃圾桶文件 trash-put移入垃圾桶 trash-restore恢复垃圾桶文件 trash-rm移出垃圾桶文件
trash          trash-empty    trash-list     trash-put      trash-restore  trash-rm       
[root@bogon ~]# trash-put trash-cli/
[root@bogon ~]# ls
anaconda-ks.cfg
[root@bogon ~]# trash-list 
2019-12-07 17:02:47 /etc/yum.repos.d/docker-ce.repo
2019-12-07 17:10:11 /root/trash-cli
[root@bogon ~]# 
原文地址:https://www.cnblogs.com/biaopei/p/12002600.html