SafeRM is a custom shell script that provides an extra layer of protection when using the rm -rf
command. It prompts the user for confirmation before deleting files and directories, helping to prevent accidental data loss.
- Copy the
saferm
file to the/usr/local/bin
directory. chmod +x /usr/local/bin/saferm
- Edit the
~/.bashrc
file, add an alias forrm
as follows:
alias rm='/usr/local/bin/saferm'
source ~/.bashrc
curl -o /usr/local/bin/saferm https://raw.githubusercontent.com/kookob/safe-rm/master/saferm && sudo chmod +x /usr/local/bin/saferm && echo "alias rm='/usr/local/bin/saferm'" >> ~/.bashrc && source ~/.bashrc
wget -P /usr/local/bin https://raw.githubusercontent.com/kookob/safe-rm/master/saferm && sudo chmod +x /usr/local/bin/saferm && sudo echo "alias rm='/usr/local/bin/saferm'" >> ~/.bashrc && source ~/.bashrc
alias rm
If you see the following content, it means rm -rf /
to prevent accidental deletion has taken effect.
alias rm='/usr/local/bin/saferm'
- rm -rf /
- rm -rf /*
- rm -rf * (root directory)
- rm -rf ./* (root directory)
- rm -rf /bin
- Other root directory scenarios, and so on.
MIT