58 lines
893 B
Markdown
Executable File
58 lines
893 B
Markdown
Executable File
# 查看目录大小
|
||
|
||
## 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)
|