使用safe-rm替换rm命令,防止误删除
1.下载safe源码包:
wget https://launchpad.net/safe-rm/trunk/0.12/+download/safe-rm-0.12.tar.gz
2.解压safe-rm
tar -zxf safe-rm-0.12.tar.gz
3.复制safe-rm到/usr/local/bin目录下
cp safe-rm-0.12/safe-rm /usr/local/bin/rm
4.添加环境变量
vim /etc/profile
#在最后一行添加
PATH=/usr/local/bin:$PATH
保存后使其生效
source /etc/profile
5.配置路径黑名单
vim /etc/safe-rm.conf
#添加要删除的路径按行分隔
/
/*
/home/test
6.测试删除test文件夹
mkdir /home/test
rm -rf /home/test