前序
安装有道词典时,安装成功后发现用不了,因此卸载程序(官方没有提供卸载脚本)改install.sh文件将新增加的文件rm掉以此方式来卸载,结果脚本没改好把系统文件给误删除啦。rm 文件得谨慎操作,因为如果用rm删除文件后是无法恢复的,将文件丢弃到垃圾桶可以很好的起到缓冲确认作用不至于误删后恢复不了。
安装 trash程序
1、在命令创建键入:trash
如果已经安装会有trash的提示信息,如果没有安装也会有提示安装的命令( apt install trash-cli )
2、我机器没有安装过以此使用提示给的安装脚本安装程序:
sudo apt install trash-cli
3、安装完成。
trash 命令使用
查询命令帮助文档:trash --help
将目录或文件丢弃到垃圾桶:trash 目录/文件
smqk@lenovo:~$ trash --help Usage: trash [OPTION]... FILE... Put files in trash Options: --version show program's version number and exit -h, --help show this help message and exit -d, --directory ignored (for GNU rm compatibility) -f, --force ignored (for GNU rm compatibility) -i, --interactive ignored (for GNU rm compatibility) -r, -R, --recursive ignored (for GNU rm compatibility) -v, --verbose explain what is being done To remove a file whose name starts with a `-', for example `-foo', use one of these commands: trash -- -foo trash ./-foo Report bugs to http://code.google.com/p/trash-cli/issues
回收站文件位置
默认回收后位置: ~/.local/share/Trash/
使用sudo 回收位置:/.Trash/
回收站文件目录结构
expunged 不知道有啥卵用;
files 被回收的文件;
info 存在被回收文件的描述信息(文件的原始路径等等信息);
回收站文件还原
回收站文件还原图形界面的还原就不用说啦,使用sudo 回收的文件就可能在你的图形界面中不显示啦此时还原就需要通过命令行将/.Trash/中你想还原的文件mv到原因的位置即可。
实操
如下,有道官网提供的安装脚本和自己写的(uninstall.sh)卸载脚本,曾经就写使用rm 来写卸载有道脚本结果弄错啦把系统图标都给删除啦(当时脚本:rm -rf $PREFIX/share/icons/hicolor/),还好有同事也使用Ubantu 开发(解决办法是将他系统的这个目录全部拷贝给我)。