目录
安装trash-cli
# 更换国内源
rambo@debian:~$ cat /etc/apt/sources.list
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
# 创建示例文件
rambo@debian:~$ echo 123 > 1.txt
rambo@debian:~$ mkdir opop && echo 456 > opop/2.txt
# 安装trash-cli
rambo@debian:~$ sudo apt-get install trash-cli
# 查看回收站时为空
rambo@debian:~$ trash-list
# 不建议超级用户使用这样的别名
rambo@debian:~$ vim ~/.bashrc
alias rm=trash-put
rambo@debian:~$ source .bashrc
# 将1.txt文件和opop目录移动到回收站中
rambo@debian:~$ trash-put 1.txt opop 或者 rm -rf 1.txt opop(在做了别名的前提下可这样操作)
# 查看回收站中已删除的文件
rambo@debian:~$ trash-list
2023-10-16 02:24:55 /home/rambo/1.txt
2023-10-16 02:24:55 /home/rambo/opop
# 从回收站中恢复文件或目录
rambo@debian:~$ trash-restore
0 2023-10-16 02:24:55 /home/rambo/1.txt
1 2023-10-16 02:24:55 /home/rambo/opop
What file to restore [0..1]: 0 # 询问你想恢复的文件或目录,这里我选择0,即1.txt,只能使用该方式恢复
rambo@debian:~$ cat 1.txt
123
# 从回收站中删除文件
rambo@debian:~$ trash-rm opop
rambo@debian:~$ trash-list # 再次查看回收站时将为空
# 删除超过 N 天的垃圾文件:或者可删除回收站中超过 N 天的文件
rambo@debian:~$ trash-empty 30 # 删除回收站中超过 10 天的文件
autotrash
rambo@debian:~$ sudo apt-get install -y pipx
rambo@debian:~$ pipx install autotrash
# 添加到环境变量中
rambo@debian:~$ pipx ensurepath
往后的步骤需要自己来完成....
标签:non,rambo,https,free,误删,防止,linux,main,debian
From: https://www.cnblogs.com/smlile-you-me/p/17767310.html