给linux添加回收站

2018-02-01 22:09:18

linux下常常使用rm,导致误操作删除一些重要的文档,很难恢复(当然也能恢复,不过比较复杂),所以在这种情况下,我们如果能给linux添加一个回收站就好多了,说白了,这个回收站机制也比较简单,就是使用  mv封装一个rm,简单的可以自己写个脚本,复杂点的就是在bin下添加这个封装命令就行了。

给linux添加一个回收站。
mkdir /tmp/trash_tmp 建立一个回收站目录
vi /bin/trash 编辑一个文件
mv $@ /tmp/trash_tmp
:wq 保存退出
alias rm=/bin/trash添加别名
vi /etc/bashrc
在最后一行添加alias rm=/bin/trash
chmod 755 /bin/trash
chmod 777 /tmp/trash_tmp
source /etc/bashrc 启用环境变量
如果要真的删除某个文件的时候用 /bin/rm -i file_name
这样一来一个回收站就建立了,以后用rm的时候会自动的将file_name 移动到/tmp/trash_tmp/目录下

  • 2017-11-06 01:00:17

    撤销git add

    如何撤销git add,不小心执行了git add . 操作,但是又不能提交所有的文件,因为对应不同的分支,现在怎么样可以将git add 撤销回来

  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.