Linux系统本身并没有像Windows那样的内置回收站功能,但用户可以通过几种方法来模拟回收站的功能并进行数据备份和恢复。以下是一些常见的方法:
使用 trash-cli
工具:
trash-cli
:sudo apt-get install trash-cli
trash-put /path/to/file
trash-list
trash-restore /path/to/file
使用别名:
.bashrc
或 .zshrc
文件中添加别名,将 rm
命令重定向到一个自定义的删除脚本:alias rm='/path/to/custom/script.sh'
使用文件管理器:
创建回收站目录:
/.trash
。rm
命令重定向到这个目录:alias rm='mv -t /.trash'
使用 tar
命令进行归档备份:
tar -czvf backup.tar.gz /path/to/source
使用 rsync
命令进行增量备份:
rsync -avz /path/to/source user@remote_host:/remote/backup/
使用 duplicity
命令进行加密备份:
duplicity --full-if-older-than 1M /path/to/source sftp://user@remote_host/backups/
使用 lsof
命令查找被删除的文件:
lsof /path/to/file
使用 debugfs
命令恢复文件:
debugfs -w /dev/sdXX -c "find /path/to/file" -r -f filename
使用数据恢复工具:
TestDisk
或 PhotoRec
等工具进行数据恢复。