safe-rm 代替 rm 防止误删除重要东西
特别是防止 rm -rf /
1、下载safe-rm,下载地址:https://launchpad.net/safe-rm/+download
wget https://launchpadlibrarian.net/188958703/safe-rm-0.12.tar.gz
2、解压safe-rm
tar -zxvf safe-rm-0.12.tar.gz
3、重命名safe-rm并移动到/usr/local/bin目录下
mv safe-rm /usr/local/bin/rm
4、修改环境变量
#safe-rm,此条放在其它export前面
export PATH=/usr/local/bin:/bin:/usr/bin:$PATH
#保存后使环境变量生效
source /etc/profile
5、配置safe-rm配置文件,添加受保护的目录或者文件:
safe-rm已经将一些系统重要的文件默认保护了起来,我们在这里可以添加自定义的safe-rm.conf
vim /etc/safe-rm.conf
#在文件中每行添加一条
/data/*
/data/test
#添加完成后保存即可
/
/*
/bin
/boot
/dev
/etc
/home
/initrd
/lib
/proc
/root
/sbin
/sys
/usr
/usr/bin
/usr/include
/usr/lib
/usr/local
/usr/local/bin
/usr/local/include
/usr/local/sbin
/usr/local/share
/usr/sbin
/usr/share
/usr/src
/var
/etc/safe-rm.conf
/bin/
/boot/
/dev/
/etc/
/home/
/initrd/
/lib/
/proc/
/root/
/sbin/
/sys/
/usr/
/usr/bin/
/usr/include/
/usr/lib/
/usr/local/
/usr/local/bin/
/usr/local/include/
/usr/local/sbin/
/usr/local/share/
/usr/sbin/
/usr/share/
/usr/src/
/var/
/bin/*
/boot/*
/dev/*
/etc/*
/home/*
/initrd/*
/lib/*
/proc/*
/root/*
/sbin/*
/sys/*
/usr/*
/usr/bin/*
/usr/include/*
/usr/lib/*
/usr/local/*
/usr/local/bin/*
/usr/local/include/*
/usr/local/sbin/*
/usr/local/share/*
/usr/sbin/*
/usr/share/*
/usr/src/*
/var/*