Linux中回收站可以自定义,用户可根据需求调整回收站的路径、大小限制、保留时间等设置,具体方法因桌面环境(如GNOME、KDE Plasma)和工具(如命令行、图形界面)而异。
dconf-editor(sudo apt install dconf-editor),打开后导航至org -> gnome -> desktop -> trash,双击location键,输入自定义路径(如file:///mnt/custom-trash),保存后生效。~/.config/dconf/user文件,添加或修改[org/gnome/desktop/trash]部分的location值(如location='file:///mnt/custom-trash'),保存后重启系统或重新登录。~/.config/plasma-org.kde.trashrc文件,找到[Trash]部分,修改Location值为自定义路径(如Location=file:///mnt/custom-trash),保存后生效。org -> gnome -> desktop -> trash路径下,修改max-size键的值(单位:字节,如1073741824表示1GB)。安装trash-cli后,通过环境变量设置大小限制:在~/.bashrc或~/.zshrc中添加export TRASH_MAX_SIZE=2147483648(2GB),重启终端后生效。
org -> gnome -> desktop -> trash路径下,修改max-age键的值(单位:天,如30表示保留30天)。find ~/.local/share/Trash/files -type f -mtime +30 -exec rm -f {} \;),通过crontab -e添加定时任务(如0 0 * * * /path/to/script.sh)。trash-restore恢复文件、trash-empty清空回收站,支持更多自定义操作(如指定删除文件的回收站路径)。注:自定义前需确保自定义路径存在且具备读写权限(如mkdir -p /mnt/custom-trash),避免配置无效。不同发行版(如Ubuntu、Fedora)的图形界面可能略有差异,但核心逻辑一致。