Linux 没有回收站,rm 错删文件文件就回不来了,教训实在太惨痛。从 pansz 在知乎上对基于文本的 Linux 为什么没有回收站?的回答中得知,linux 也有类似回收站的工具 trash-cli
。这篇日志记录下没有 root 权限下的安装过程。
$ git clone https://github.com/andreafrancia/trash-cli.git
$ cd trash-cli
$ python setup.py install --user
事实上,用 pip 更方便,不过我因为看的资料缘故先用了前者
pip install trash-cli --user
上面安装好后,只能用 ~/.local/bin/trash-put test.txt
这样的方式使用,我们还要让系统能够知道从 ~/.local/bin
这里找到这些命令。
用 vim 打开 ~/.bash_profile
文件,在最后添加下面代码
export PATH="/work/yimian/.local/bin/:$PATH"
/work/yimian
是我这里的绝对路径,替换成你自己的 trash-put 所在的绝对路径就好
具体看这个链接 https://www.ostechnix.com/trash-cli-command-line-trashcan-unix-like-systems/
主要就是 ,
, , ,
trash-put
: 将某些文件放入 trashtrash-list
: 查看 trash 中的所有文件trash-restore
: 恢复 trash 中的某个文件trash-rm
: 单独删除 trash 中的文件trash-empty
: 清空 trash