结论与总体思路
可以调整,但方式与桌面系统不同。centos 服务器版默认没有统一的图形化回收站;命令行删除的文件是否进入回收站取决于你使用的工具。常见做法是:使用支持回收站的命令行工具(如 trash-cli),并通过配额或定时清理来限制其占用空间;或在 gnome 桌面下使用 gvfs 的回收站机制并配合配额/脚本控制容量。
可行方案
常见误区与纠正
- 没有统一的“系统级回收站大小”参数可直接修改;回收站行为取决于具体工具(命令行或桌面环境)。
- 网络流传的“修改 /etc/trash.conf 并设置 max_size/keep_days 即可生效”的做法并不适用于主流发行版;trash-cli 本身不提供“最大容量”配置项,需借助配额或脚本实现。
- “rsync.conf 里设置 quota 就能限制回收站大小”的说法与回收站无关,rsync 配额并非回收站容量控制机制。
快速实施示例脚本
- 按最大容量清理(保留最新文件,直到总大小不超过上限)
- 示例(限制为 10gb):
- max_size=10737418240 # 10gb,单位字节
- trash_dir=“$home/.local/share/trash/files”
- cur=$(du -sb “$trash_dir” 2>/dev/null | awk ‘{print $1}’)
- if [ “$cur” -gt “$max_size” ]; then
find “$trash_dir” -mindepth 1 -maxdepth 1 -printf ‘%T@ %p\n’ | sort -n | cut -d’ ’ -f2- | while read f; do
rm -rf “$f” && cur=$(du -sb “$trash_dir” 2>/dev/null | awk ‘{print $1}’) && [ “$cur” -le “$max_size” ] && break
done
fi
- 加入 cron(每天清理一次):0 2 * * * /path/to/clean_trash.sh
- 按保留天数清理(如保留 30 天)
- find ~/.local/share/trash/files -type f -atime +30 -delete
- find ~/.local/share/trash/info -type f -atime +30 -delete
- cron 示例:0 2 * * * /path/to/clean_trash.sh