在Ubuntu中清理大文件,可以遵循以下步骤:
find
命令:find / -type f -size +100M
:查找根目录下所有大于100MB的文件。find / -type f -size +500M
:查找根目录下所有大于500MB的文件。find / -type f -size +1G
:查找根目录下所有大于1GB的文件。ncdu
工具:ncdu
:sudo apt-get install ncdu
ncdu /path/to/directory
来查看指定目录下的大文件。ls -lh
命令查看文件大小和详细信息。file
命令确定文件类型。rm
命令删除:rm /path/to/large/file
rm -rf /path/to/directory/*
(注意:此操作不可逆,请谨慎使用)gzip
、bzip2
或xz
等压缩工具减小文件大小:gzip /path/to/large/file
.gz
、.bz2
或.xz
为扩展名。mv /path/to/large/file /path/to/external/storage
sudo apt-get clean
命令清理APT包缓存。/tmp
目录下的临时文件:sudo rm -rf /tmp/*
df -h
命令查看磁盘空间使用情况。