Files
chill_notes/Linux/Tools/查看目录大小.md
2026-04-21 20:24:09 +08:00

58 lines
893 B
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 查看目录大小
## du 命令
```bash
# 查看当前目录总大小
du -sh
# 查看当前目录下各子目录大小
du -h --max-depth=1
# 查看指定目录大小
du -sh /path/to/dir
# 查看目录下各子目录大小
du -sh /path/to/dir/*
# 按大小排序显示(当前目录)
du -sh * | sort -rh
# 查看隐藏目录
du -sh .[!.]* 2>/dev/null
# 查找大于 100M 的文件
find . -type f -size +100M -exec du -h {} \;
```
## df 命令(查看磁盘使用情况)
```bash
# 查看磁盘使用情况
df -h
# 查看 inode 使用情况
df -i
# 查看特定文件系统
df -h /home
```
## ncdu更友好的交互式工具
```bash
# 安装
yum install ncdu # CentOS
apt install ncdu # Ubuntu
# 交互式查看(按大小排序)
ncdu /
# 只显示大于 100MB
ncdu --max-size 100M /
```
---
> 参考:[du 命令详解](https://www.hack520.com/504.html)