safedelete 能暫存刪除的檔案, 讓 safedelete 取代 rm, 就能讓 Linux console 擁有 "資源回收筒" 的功能.
safedelete 下載點: http://linux./sec/safedelete.html
vi ~/.bashrc
export SAFEDAYS=30 |
刪除的檔案保存 30 天 |
alias rm=‘/usr/bin/safedelete‘ |
使用 safedelete 取代 rm 刪檔, 將刪除的檔案保存至資源回收筒 (~/.trash) |
alias purge=‘/bin/rm -i‘ |
真正要刪除檔案時以 purge 取代 rm 指令 |
指令備忘
- undelete -l (小寫 L) 顯示資源回收筒裡所有的檔案
- undelete -i 顯示資源回收筒裡所有的檔案 (詳細資料)
- safedelchk 清除在資源回收筒裡超過保存天數 (SAFEDAYS) 的檔案.
應用實例 (以下 rm 為 alias rm=‘/usr/bin/safedelete‘ 的 rm)
cd /tmp
echo "test" > test.txt
rm test.txt
undelete test.txt (救回當前目錄底下的指定檔案)
cd ~
echo "test" > test.txt
cd /tmp
echo "abc" > abc.txt
rm ~/test.txt test.txt
undelete -p *.txt -a (救回所有符合條件的檔案)
cd /tmp
mkdir test
cd test
touch a b c
cd ..
rm -rf test
undelete -p /tmp/test/* -a (救回指定目錄)
補充: 救回在 ext2 檔案系統被 rm 刪除的檔案
telinit S
debugfs /dev/hda5
lsdel
stat 123456
dump 123456 /path/to/savefile
quit
延伸閱讀: