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
#添加要删除的路径按行分隔
/
/*
/xxx/xxx
/root/test
6.测试删除test文件夹
mkdir /root/test
rm -rf /root/test