修改 ~/.bashrc
文件,适当位置加入以下代码:
# Alias configuration for dangerous operations
# 危险操作的别名配置
alias rm='rm -i' # 删除文件前确认
alias mv='mv -i' # 移动或覆盖文件前确认
alias cp='cp -i' # 复制文件前确认
alias rmrf='echo "Are you sure you want to run rm -rf? (y/n)" && read answer && [ "$answer" = "y" ] && rm -rf' # 递归删除前确认
alias overwrite='echo "Are you sure you want to overwrite the file? (y/n)" && read answer && [ "$answer" = "y" ] && >' # 覆盖文件前确认
alias emptyfile='echo "Are you sure you want to empty the file? (y/n)" && read answer && [ "$answer" = "y" ] && : >' # 清空文件前确认
alias exit='echo "Are you sure you want to exit? (y/n)" && read answer && [ "$answer" = "y" ] && exit' # 退出终端前确认
alias reboot='echo "Are you sure you want to reboot the system? (y/n)" && read answer && [ "$answer" = "y" ] && reboot' # 重启系统前确认
alias shutdown='echo "Are you sure you want to shutdown the system? (y/n)" && read answer && [ "$answer" = "y" ] && shutdown' # 关机前确认
alias kill9='echo "Are you sure you want to kill the process? (y/n)" && read answer && [ "$answer" = "y" ] && kill -9' # 强制终止进程前确认
然后运行:source ~/.bashrc