在 Ubuntu 中,“清理历史记录”通常指命令行历史、系统日志、浏览器记录、软件缓存等。下面按常见场景给你一个完整、实用的清理指南。
history -c
只清空当前 shell 的内存历史,不会立即删除文件
rm ~/.bash_history
或(如果使用 zsh):
rm ~/.zsh_history
unset HISTFILE
export HISTSIZE=0
⚠️ 谨慎操作,不要直接删除目录
du -sh /var/log/*
sudo journalctl --vacuum-time=7d
只保留最近 7 天日志
sudo truncate -s 0 /var/log/syslog
sudo apt clean
sudo apt autoclean
sudo apt autoremove
rm -rf ~/.cache/*
rm -rf ~/.cache/thumbnails/*
rm -rf ~/.mozilla/firefox/*.default-release/storage
或在浏览器中:
设置 → 隐私与安全 → 清除历史记录
rm -rf ~/.config/google-chrome/Default/Local\ Storage
rm -rf ~/.local/share/recently-used.xbel
或:
gsettings set org.gnome.desktop.privacy remember-recent-files false
sudo apt install bleachbit
图形界面:
bleachbit
命令行示例:
sudo bleachbit --clean system.cache system.tmp
history -c
rm ~/.bash_history
rm -rf ~/.cache/*
sudo apt clean
sudo apt autoremove -y
sudo journalctl --vacuum-time=7d
rm -rf /var/log如果你能告诉我:
我可以给你更精准、低风险的清理方案 ✅