trash-cli设置Linux 回收站

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了trash-cli设置Linux 回收站相关的知识,希望对你有一定的参考价值。

trash-cli 设置 Linux 回收站

trash-cli是一个使用 python 开发的软件包,包含 trash-put、restore-trash、trash-list、trash-empty、trash-rm等命令,我们可以通过这条命令,将文件移动到回收站,或者还原删除了的文件。

trash-cli的项目地址:https://github.com/andreafrancia/trash-cli

系统:CentOS 6.8

  • 安装
下载地址:https://github.com/andreafrancia/trash-cli
cd /tmp
unzip trash-cli-master.zip
cd trash-cli-master
python setup.py install

安装过程

[[email protected] trash-cli-0.17.1.14]# python setup.py install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/trashcli
copying trashcli/trash.py -> build/lib/trashcli
copying trashcli/list.py -> build/lib/trashcli
copying trashcli/empty.py -> build/lib/trashcli
copying trashcli/list_mount_points.py -> build/lib/trashcli
copying trashcli/rm.py -> build/lib/trashcli
copying trashcli/__init__.py -> build/lib/trashcli
copying trashcli/put.py -> build/lib/trashcli
copying trashcli/fstab.py -> build/lib/trashcli
copying trashcli/restore.py -> build/lib/trashcli
copying trashcli/fs.py -> build/lib/trashcli
copying trashcli/cmds.py -> build/lib/trashcli
running build_scripts
creating build/scripts-2.6
copying and adjusting trash -> build/scripts-2.6
copying and adjusting trash-put -> build/scripts-2.6
copying and adjusting trash-list -> build/scripts-2.6
copying and adjusting trash-restore -> build/scripts-2.6
copying and adjusting trash-empty -> build/scripts-2.6
copying and adjusting trash-rm -> build/scripts-2.6
changing mode of build/scripts-2.6/trash from 644 to 755
changing mode of build/scripts-2.6/trash-put from 644 to 755
changing mode of build/scripts-2.6/trash-list from 644 to 755
changing mode of build/scripts-2.6/trash-restore from 644 to 755
changing mode of build/scripts-2.6/trash-empty from 644 to 755
changing mode of build/scripts-2.6/trash-rm from 644 to 755
running install_lib
creating /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/trash.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/list.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/empty.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/list_mount_points.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/rm.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/__init__.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/put.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/fstab.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/restore.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/fs.py -> /usr/lib/python2.6/site-packages/trashcli
copying build/lib/trashcli/cmds.py -> /usr/lib/python2.6/site-packages/trashcli
byte-compiling /usr/lib/python2.6/site-packages/trashcli/trash.py to trash.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/list.py to list.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/empty.py to empty.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/list_mount_points.py to list_mount_points.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/rm.py to rm.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/put.py to put.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/fstab.py to fstab.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/restore.py to restore.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/fs.py to fs.pyc
byte-compiling /usr/lib/python2.6/site-packages/trashcli/cmds.py to cmds.pyc
running install_scripts
copying build/scripts-2.6/trash-rm -> /usr/bin
copying build/scripts-2.6/trash-list -> /usr/bin
copying build/scripts-2.6/trash-put -> /usr/bin
copying build/scripts-2.6/trash -> /usr/bin
copying build/scripts-2.6/trash-restore -> /usr/bin
copying build/scripts-2.6/trash-empty -> /usr/bin
changing mode of /usr/bin/trash-rm to 755
changing mode of /usr/bin/trash-list to 755
changing mode of /usr/bin/trash-put to 755
changing mode of /usr/bin/trash to 755
changing mode of /usr/bin/trash-restore to 755
changing mode of /usr/bin/trash-empty to 755
running install_data
copying man/man1/trash-empty.1 -> /usr/share/man/man1
copying man/man1/trash-list.1 -> /usr/share/man/man1
copying man/man1/trash-restore.1 -> /usr/share/man/man1
copying man/man1/trash-put.1 -> /usr/share/man/man1
copying man/man1/trash-rm.1 -> /usr/share/man/man1
running install_egg_info
Writing /usr/lib/python2.6/site-packages/trash_cli-0.17.1.14-py2.6.egg-info
[[email protected] trash-cli-0.17.1.14]#
  • 安装成功后我们的系统就有了以下工具.
[[email protected] ~]# ll /usr/bin/|grep trash
-rwxr-xr-x    1 root root        123 2月  18 15:26 trash
-rwxr-xr-x    1 root root        125 2月  18 15:26 trash-empty
-rwxr-xr-x    1 root root        124 2月  18 15:26 trash-list
-rwxr-xr-x    1 root root        123 2月  18 15:26 trash-put
-rwxr-xr-x    1 root root        127 2月  18 15:26 trash-restore
-rwxr-xr-x    1 root root        122 2月  18 15:26 trash-rm
[[email protected] ~]#
  • 功能说明
命令概览:

trash-put          将文件或目录移入回收站

trash-empty        清空回收站

trash-list         列出回收站中的文件

trash-restore      还原回收站中的文件

trash-rm           删除回首站中的单个文件
  • 用它替代 rm命令
[[email protected] ~]# vim /etc/.bashrc
# 添加下面一行
alias rm=”trush-put”

使修改的别名生效:

[[email protected] ~]# source /etc/bashrc

默认存放路径:/~/.local/share/Trash/files/

以上是关于trash-cli设置Linux 回收站的主要内容,如果未能解决你的问题,请参考以下文章

trash-cli,Linux 的命令行回收站

ubuntu/linux trash-cli 删除文件到回收站 类似回收站机制的删除

Linux系统防止误删除文件

《现代命令行工具指南》9. 删除文件:让删除文件变得安全可控 - trash-cli

《现代命令行工具指南》9. 删除文件:让删除文件变得安全可控 - trash-cli

Linux(Ubuntu)使用日记------trash-cli防止误删文件