Ubuntu 回收站设置指南
一 图形界面可做的设置
gconf-editor,定位到 apps → nautilus → desktop,勾选或取消 trash_icon_visible。提示:较新的 GNOME 已弃用 gconf-editor,请优先使用“设置”或 dconf-editor。二 命令行与回收站策略
sudo apt-get install trash-clitrash <文件/目录>trash-listtrash-restoretrash-empty~/.bashrc 或 ~/.zshrc 中添加 alias rm='trash',之后 rm 会调用回收站;需要强制删除时用 /bin/rm -i 或 /bin/rm -rf。mkdir -p ~/.trash~/.bashrc 中加入示例函数(含 trash、restore、rmtrash 等),保存后执行 source ~/.bashrc 生效。rm 默认不经过回收站,上述别名或脚本可统一体验。三 定时自动清理与保留策略
sudo apt-get install trash-cli/etc/systemd/system/trash-cleanup.service:[Unit]
Description=Custom Trash Cleanup
[Service]
Type=oneshot
ExecStart=/usr/bin/trash-empty --age 7d
/etc/systemd/system/trash-cleanup.timer:[Unit]
Description=Run trash cleanup daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload && sudo systemctl enable --now trash-cleanup.timertrash-empty --age 7d 表示清理回收站中超过 7 天 的项目;也可改为每周、每月等周期。