在Linux系統中,有許多實用的清理命令可以幫助你釋放磁盤空間、刪除不必要的文件和優化系統性能。以下是一些常用的Linux清理命令及其實用技巧:
df -hgrep過濾特定分區或文件系統。df -h | grep '/dev/sda1'
du -sh *sort按大小排序。du -sh * | sort -h
rm-r遞歸刪除目錄。-f強制刪除,不提示確認。rm -rf /path/to/directory
findfind /path/to/search -type f -size +100M -exec rm {} \;
ncdu-r遞歸掃描目錄,使用-q靜默模式。ncdu -r /path/to/directory
bleachbitapt-get cleansudo apt-get clean
yum clean allsudo yum clean all
systemd-cleanup--time=30d刪除30天前的日志。sudo systemd-cleanup --time=30d
tmpwatchsudo tmpwatch 24h /tmp/*
logrotate/etc/logrotate.conf或相關配置文件。fstrimsudo fstrim /
rm -rf時要格外小心,因為它會無提示地刪除所有內容。通過合理使用這些命令和技巧,你可以有效地管理和優化Linux系統的存儲空間。