trash-cli是一個使用 python 開發的軟件包,包含 trash-put、restore-trash、trash-list、trash-empty、trash-rm等命令,咱們能夠經過這寫命令,將文件移動到回收站,或者還原刪除了的文件。
trash-cli的項目地址:trash-cli下載地址python
轉載於http://www.seiang.com/?p=229git
一、下載trash-cli安裝包github
- [root@VM_54_118_centos others]# git clone https://github.com/andreafrancia/trash-cli.git
- Cloning into 'trash-cli'...
- remote: Enumerating objects: 4556, done.
- remote: Total 4556 (delta 0), reused 0 (delta 0), pack-reused 4556
- Receiving objects: 100% (4556/4556), 1.17 MiB | 716.00 KiB/s, done.
- Resolving deltas: 100% (2791/2791), done.
- 進入下載目錄
- [root@VM_54_118_centos others]# cd trash-cli/
- [root@VM_54_118_centos trash-cli]# ll
- total 112
- -rw-r--r-- 1 root root 251 Feb 2 17:29 bugs.txt
- -rw-r--r-- 1 root root 4766 Feb 2 17:29 check_release_installation.py
- -rw-r--r-- 1 root root 17992 Feb 2 17:29 COPYING
- -rw-r--r-- 1 root root 1432 Feb 2 17:29 CREDITS.txt
- drwxr-xr-x 3 root root 4096 Feb 2 17:29 docs
- -rw-r--r-- 1 root root 782 Feb 2 17:29 DONE.txt
- -rw-r--r-- 1 root root 3408 Feb 2 17:29 HISTORY.txt
- -rwxr-xr-x 1 root root 240 Feb 2 17:29 install-rpm.sh
- drwxr-xr-x 2 root root 4096 Feb 2 17:29 integration_tests
- drwxr-xr-x 3 root root 4096 Feb 2 17:29 man
- -rw-r--r-- 1 root root 78 Feb 2 17:29 MANIFEST.in
- -rw-r--r-- 1 root root 4774 Feb 2 17:29 README.rst
- -rw-r--r-- 1 root root 24 Feb 2 17:29 requirements-dev.txt
- -rwxr-xr-x 1 root root 293 Feb 2 17:29 setup.cfg
- -rw-r--r-- 1 root root 2423 Feb 2 17:29 setup.py
- drwxr-xr-x 2 root root 4096 Feb 2 17:29 tasks
- -rw-r--r-- 1 root root 799 Feb 2 17:29 TODO.txt
- drwxr-xr-x 2 root root 4096 Feb 2 17:29 trashcli
- -rwxr-xr-x 1 root root 127 Feb 2 17:29 trash-put
- -rwxr-xr-x 1 root root 126 Feb 2 17:29 trash-rm
- drwxr-xr-x 2 root root 4096 Feb 2 17:29 unit_tests
- -rw-r--r-- 1 root root 243 Feb 2 17:29 Vagrantfile
二、開始安裝vim
- [root@VM_54_118_centos trash-cli]# python setup.py install
- .......
- running install_scripts
- copying build/scripts-2.7/trash-rm -> /usr/bin
- copying build/scripts-2.7/trash-list -> /usr/bin
- copying build/scripts-2.7/trash-put -> /usr/bin
- copying build/scripts-2.7/trash-empty -> /usr/bin
- copying build/scripts-2.7/trash -> /usr/bin
- copying build/scripts-2.7/trash-restore -> /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-empty to 755
- changing mode of /usr/bin/trash to 755
- changing mode of /usr/bin/trash-restore 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.7/site-packages/trash_cli-0.17.1.14-py2.7.egg-info
三、安裝成功後咱們的系統就有了如下工具.centos
- [root@VM_54_118_centos ~]# ll /usr/bin/ | grep trash
- -rwxr-xr-x 1 root root 123 Feb 2 17:43 trash
- -rwxr-xr-x 1 root root 125 Feb 2 17:43 trash-empty
- -rwxr-xr-x 1 root root 124 Feb 2 17:43 trash-list
- -rwxr-xr-x 1 root root 123 Feb 2 17:43 trash-put
- -rwxr-xr-x 1 root root 127 Feb 2 17:43 trash-restore
- -rwxr-xr-x 1 root root 122 Feb 2 17:43 trash-rm
功能說明:bash
trash-put 將文件或目錄移入回收站
trash-empty 清空回收站
trash-list 列出回收站中的文件
trash-restore還原回收站中的文件
trash-rm 刪除回首站中的單個文件工具
四、安裝完畢以後咱們能夠經過一些配置,用它替代 rm命令測試
- [root@VM_54_118_centos ~]# vim .bashrc
- # .bashrc
- #alias rm='rm -i'
- alias rm='trash-put'
五、實驗測試ui
刪除測試:url
- [root@VM_54_118_centos ~]# rm -rf dump.rdb
- [root@VM_54_118_centos ~]# ll ~/.local/share/Trash/files
- -rw-r--r-- 1 root root 123 Jul 17 2018 dump.rdb
- [root@VM_54_118_centos ~]# trash-list
- 2019-02-02 18:02:33 /root/dump.rdb
還原刪除的文件
- [root@VM_54_118_centos ~]# trash-restore /root/dump.rdb
- 0 2019-02-02 18:01:08 /root/dump.rdb.bak
- 1 2019-02-02 18:02:33 /root/dump.rdb
- What file to restore [0..1]: 1
- 還原成功
- [root@VM_54_118_centos ~]# ll /root/dump.rdb
- -rw-r--r-- 1 root root 123 Jul 17 2018 /root/dump.rdb
備註:
trash-put命令會把咱們想要刪除的文件移動到~/.local/share/Trash/files 中。相關信息記錄在~/.local/share/Trash/info中。