1. 磁盘空间查看命令df
- df -a = df : 查看所有挂载点的空间统计情况
➜ df -a
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 489620264 21472112 216114224 10% 484226 2447617094 0% /
devfs 382 382 0 100% 664 0 100% /dev
/dev/disk1s1 489620264 239025344 216114224 53% 1843336 2446257984 0% /System/Volumes/Data
/dev/disk1s4 489620264 10487920 216114224 5% 6 2448101314 0% /private/var/vm
map auto_home 0 0 0 100% 0 0 100% /System/Volumes/Data/home
/Users/xxx/Downloads/Visual Studio Code.app 489620264 237803912 219432808 53% 1799185 2446302135 0% /private/var/folders/vq/ljbtx4qx0rsdyfvtvzwwmy9m0000gn/T/AppTranslocation/1676D9D6-9F8E-404F-A235-0349DA11B70D
➜ df
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 489620264 21472112 216113936 10% 484226 2447617094 0% /
devfs 382 382 0 100% 664 0 100% /dev
/dev/disk1s1 489620264 239025632 216113936 53% 1843336 2446257984 0% /System/Volumes/Data
/dev/disk1s4 489620264 10487920 216113936 5% 6 2448101314 0% /private/var/vm
map auto_home 0 0 0 100% 0 0 100% /System/Volumes/Data/home
/Users/xxx/Downloads/Visual Studio Code.app 489620264 237803912 219432808 53% 1799185 2446302135 0% /private/var/folders/vq/ljbtx4qx0rsdyfvtvzwwmy9m0000gn/T/AppTranslocation/1676D9D6-9F8E-404F-A235-0349DA11B70D
- df -b(g/P/k/m) : 按512B(或GB,512B,1KB,1MB)来展示磁盘空间统计
- df -h : 按可读性较好的容量单位来展示磁盘空间统计(下图以GB为可读性较好的单位),推荐使用-h
➜ df -g
Filesystem 1G-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 233 10 103 10% 484226 2447617094 0% /
devfs 0 0 0 100% 664 0 100% /dev
/dev/disk1s1 233 113 103 53% 1843342 2446257978 0% /System/Volumes/Data
/dev/disk1s4 233 5 103 5% 6 2448101314 0% /private/var/vm
map auto_home 0 0 0 100% 0 0 100% /System/Volumes/Data/home
/Users/xxx/Downloads/Visual Studio Code.app 233 113 104 53% 1799185 2446302135 0% /private/var/folders/vq/ljbtx4qx0rsdyfvtvzwwmy9m0000gn/T/AppTranslocation/1676D9D6-9F8E-404F-A235-0349DA11B70D
➜
➜ df -m
Filesystem 1M-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 239072 10484 105525 10% 484226 2447617094 0% /
devfs 0 0 0 100% 664 0 100% /dev
/dev/disk1s1 239072 116710 105525 53% 1843341 2446257979 0% /System/Volumes/Data
/dev/disk1s4 239072 5121 105525 5% 6 2448101314 0% /private/var/vm
map auto_home 0 0 0 100% 0 0 100% /System/Volumes/Data/home
/Users/xxx/Downloads/Visual Studio Code.app 239072 116115 107144 53% 1799185 2446302135 0% /private/var/folders/vq/ljbtx4qx0rsdyfvtvzwwmy9m0000gn/T/AppTranslocation/1676D9D6-9F8E-404F-A235-0349DA11B70D
➜ ~ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1s5 233Gi 10Gi 102Gi 10% 484226 2447617094 0% /
devfs 189Ki 189Ki 0Bi 100% 654 0 100% /dev
/dev/disk1s1 233Gi 114Gi 102Gi 53% 1843520 2446257800 0% /System/Volumes/Data
/dev/disk1s4 233Gi 6.0Gi 102Gi 6% 7 2448101313 0% /private/var/vm
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /System/Volumes/Data/home
/Users/xxx/Downloads/Visual Studio Code.app 233Gi 113Gi 105Gi 53% 1799185 2446302135 0% /private/var/folders/vq/ljbtx4qx0rsdyfvtvzwwmy9m0000gn/T/AppTranslocation/1676D9D6-9F8E-404F-A235-0349DA11B70D
- df -l : 只展示挂载在本地的文件系统空间统计
➜ ~ df -l
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 489620264 21472112 216086800 10% 484226 2447617094 0% /
/dev/disk1s1 489620264 239052768 216086800 53% 1843417 2446257903 0% /System/Volumes/Data
/dev/disk1s4 489620264 10487920 216086800 5% 6 2448101314 0% /private/var/vm
➜ ~ df -lg
Filesystem 1G-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s5 233 10 103 10% 484226 2447617094 0% /
/dev/disk1s1 233 113 103 53% 1843417 2446257903 0% /System/Volumes/Data
/dev/disk1s4 233 5 103 5% 6 2448101314 0% /private/var/vm
2. 文件目录磁盘用量统计命令du
- du = du-c :展示当前目录下所有文件夹的占用容量,
➜ terraform-provider-example git:(master) du -c
8 ./.terraform/plugins/darwin_amd64
8 ./.terraform/plugins
8 ./.terraform
48 ./provider
16 ./scripts
➜ terraform-provider-example git:(master) du
8 ./.terraform/plugins/darwin_amd64
8 ./.terraform/plugins
8 ./.terraform
48 ./provider
16 ./scripts
- du -a : 展示目录下所有文件的占用容量,不推荐使用。
- du -k(g/m/h) : 与df类似,以KB(或GB, MB,可读性较好的单位)来展示当前目录下的目录占用容量, 一般建议用-h
➜ terraform-provider-example git:(master) du -h
4.0K ./.terraform/plugins/darwin_amd64
4.0K ./.terraform/plugins
4.0K ./.terraform
24K ./provider
8.0K ./scripts
- du -h [file]:查看某文件的大小, 文件名可改成匹配符
➜ terraform-provider-example git:(master) du -h go.sum
16K go.sum
➜ terraform-provider-example git:(master) du -h go*
4.0K go.mod
16K go.sum
- du -d [depth]:查看当前目录下深度从0到[depth]的目录占用容量, du -d 0 等同于du -s, 即当前目录占用容量
➜ terraform-provider-example git:(master) du -h -d 1
4.0K ./.terraform
24K ./provider
8.0K ./scripts
248K .
- du -sh *: 查看当前目录下所有文件的占用容量
➜ terraform-provider-example git:(master) du -sh *
4.0K Readme.md
24K api
4.0K go.mod
16K go.sum
4.0K main.go
4.0K main.tf
4.0K makefile
24K provider
8.0K scripts
4.0K seed.json
4.0K terraform.tfstate
4.0K version