Ubuntu整理杂乱文件的实用方案
一 图形界面快速整理步骤
二 命令行高效整理
mkdir -p ~/Downloads/{Documents,Images,Videos,Archives}mv ~/Downloads/*.{pdf,docx} ~/Downloads/Documents/find ~/Downloads -type f -exec file --mime-type {} + | awk -F: '{if($2 ~ /image\//) print $1}' | xargs -I{} mv {} ~/Downloads/Images/find . -type d -empty -deletefind ~/Downloads -name "*.tmp" -print(确认无误再执行删除)find /path -name "*.log"find . -type f -size +100M -exec du -h {} +du -sh * | sort -hrename 'y/A-Z /a-z_/' *rm 删除后不可恢复;建议先 mv 到临时“待删”文件夹,观察无误再清空回收站/删除。三 自动化整理与工具
chmod +x ~/cleanup.sh
# 编辑定时任务
crontab -e
# 每天午夜执行
0 0 * * * /home/$USER/cleanup.sh
sudo apt update && sudo apt install ranger,启动:rangersudo apt update && sudo apt install mc,启动:mcsudo apt install bleachbitsudo apt install fslintsudo apt install stacer四 系统级清理与安全建议
sudo apt-get autocleansudo apt-get cleansudo apt-get autoremovejournalctl --disk-usagesudo journalctl --vacuum-time=1wsudo journalctl --vacuum-size=500Msudo rm -rf /tmp/*dpkg --list | grep linux-imagesudo apt-get purge linux-image-<旧版本号>sudo rm -rf、apt purge 等高危操作前务必备份重要数据;不确定时先请教或先移动到“待处理”目录观察。