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 等工具進行數據恢復。