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