Ubuntu回收站設置技巧匯總
dconf-editor
工具修改(需安裝:sudo apt install dconf-editor
),依次展開org->gnome->desktop->nautilus->trash
,找到max-size
選項,雙擊輸入回收站最大大?。▎挝唬鹤止?,如1GB=1073741824)。修改后自動生效。xfconf-query -c xfce4-trash -p /trash/max-size -s 100M
。trash-cli
(sudo apt install trash-cli
),創建清理腳本(如clean_recycle_bin.sh
),內容示例:#!/bin/bash
MAX_FILES=100 # 最大文件數
MAX_SIZE=100 # 最大容量(MB)
CURRENT_FILES=$(ls -1 ~/.local/share/Trash/files/* | wc -l)
CURRENT_SIZE=$(du -sm ~/.local/share/Trash/files | awk '{print $1}')
if [ "$CURRENT_FILES" -gt "$MAX_FILES" ] || [ "$CURRENT_SIZE" -gt "$MAX_SIZE" ]; then
trash-empty
fi
賦予執行權限(chmod +x clean_recycle_bin.sh
),通過crontab -e
設置定時任務(如每天凌晨1點運行:0 1 * * * /path/to/script.sh
)。autotrash
(sudo apt install autotrash
),可自動清理超過指定天數的文件(如每天清理30天前的文件):autotrash -d 30
??蓪⒋嗣钐砑拥絚ron中實現定期執行。rm -rf ~/.local/share/Trash/*
trash-cli
:trash-empty
(需安裝)。Ubuntu回收站默認無自動過期設置,但可通過以下方式實現:
0 0 1 * * /path/to/empty_trash.sh
,或使用autotrash
設置天數閾值。若系統重裝或恢復出廠設置,需重新配置回收站:
nautilus
文件管理器安裝(默認包含);gconf-editor
設置(需安裝:sudo apt install gconf-editor
),依次展開apps->nautilus->desktop
,勾選trash_icon_visible
選項,即可在桌面顯示回收站圖標。