Created
January 25, 2019 05:47
-
-
Save ayuLiao/a8d37abef323d29ed065856469e39b11 to your computer and use it in GitHub Desktop.
线上服务器应该限制所有用户的rm 权限,避免用户删除数据,而是使用mv命令来代替,创建一个mydel.sh脚本,该脚本的作用就是将要删除的数据移动到Trash文件夹下,模拟垃圾桶功能,只有管理员才有权限清楚垃圾桶的内容.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| delname=$1 | |
| if [ ! -n "$1" ]; then | |
| echo "Usages: mydel need one params which you want delelte" | |
| exit 0 | |
| fi | |
| # 将要删除的文件移动到创建好的垃圾桶目录 | |
| mv $delname /xxx/trash/ | |
| ---------------------------------------------------------------- | |
| chmod 777 mydel.sh # 给予权限 | |
| ln -s mydel.sh /usr/bin/mydel # 创建软连接 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment