查看文件linux find biggest file
Type du -a /dir/ | sort -n -r | head -n 20.
对文件进行排序
/dir 是根目录,可以自行更换
Linux使用find递归查找目录中最大的文件
在 Linux 中查找包括目录在内的最大文件的过程如下:
- 打开终端应用程序
- 使用 root 用户登录 sudo -i命令
- 类型 du -a /dir/ | sort -n -r | head -n 20
- du 将估计文件空间使用情况
- sort 会对 du 命令的输出进行排序
- head 将仅显示 /dir/ 中的前 20 个最大文件
- 还要检查 ncdu 命令 以获取目录中最大的文件
Linux 在 / 中找到最大的文件
运行命令:
$ sudo du -a /dir/ | sort -n -r | head -n 20
或者
$ sudo du -a / 2>/dev/null | sort -n -r | head -n 20
Open the terminal application
Login as root user using the sudo -i command
Type du -a /dir/ | sort -n -r | head -n 20
du will estimate file space usage
sort will sort out the output of du command
head will only show top 20 largest file in /dir/
Also check the ncdu command to get largest files in directory
Linux find a biggest files in /
Run the command:
$ sudo du -a /dir/ | sort -n -r | head -n 20
OR
$ sudo du -a / 2>/dev/null | sort -n -r | head -n 20