一.du
显示文件或目录所占用的磁盘空间
1.显示根目录所占用的磁盘空间
sh-3.2# du -sh /
100G /
2.当前目录下所有文件的大小
3.显示特定目录所占用的磁盘空间
sh-3.2# du -sh var
4.0K var
4.显示特定文件所占用的磁盘空间
sh-3.2# du -sh etc/hosts
4.0K etc/hosts
5.显示特定文件所有文件大小
sh-3.2# du -sh testdiv/*
0B testdiv/1.txt
0B testdiv/2.txt
0B testdiv/3.txt
二.df
列出文件系统的整体磁盘空间使用情况
1.默认情况
sh-3.2# df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 112Gi 100Gi 12Gi 90% 2274795 4292692484 0% /
devfs 197Ki 197Ki 0Bi 100% 680 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
2.指定多个文件或文件夹
sh-3.2# df /bin /home /usr/
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1 234573824 209142768 24919056 90% 2274808 4292692471 0% /
map auto_home 0 0 0 100% 0 0 100% /home
/dev/disk1
3.容易阅读的方式显示
sh-3.2# df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 112Gi 100Gi 12Gi 90% 2274821 4292692458 0% /
devfs 197Ki 197Ki 0Bi 100% 680 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/Microsoft AU Daemon.app 112Gi 89Gi 22Gi 81% 2283086 4292684193 0% /private/var/folders/x_/_1hh3xk50_d1k__cg29403bm0000gn/T/AppTranslocation/87FF00E5-0CD4-4653-96ED-F56386458759
/dev/disk2s1 1.4Gi 1.4Gi 6.1Mi 100% 14167 4294953112 0% /Volumes/IntelliJ IDEA
/dev/disk3s1 1.3Gi 1.3Gi 1.4Mi 100% 14900 4294952379 0% /Volumes/IntelliJ IDEA 1
/Users/honghe/Downloads/Postman.app 112Gi 93Gi 19Gi 84% 2256928 4292710351 0% /private/var/folders/x_/_1hh3xk50_d1k__cg29403bm0000gn/T/AppTranslocation/3E54EC83-CDF1-471E-A466-1148D6FDA51F
/dev/disk5
三.free
free 命令用来查看系统物理内存、交换内存和内核缓冲区内存的使用情况
1.默认用法
$ free
total used free shared buffers cached
Mem: 3922080 3773340 148740 184 282712 1050380
-/+ buffers/cache: 2440248 1481832
Swap: 4194300 0 4194300
2.友好的展示更美观
$ free -h
total used free shared buffers cached
Mem: 3.7G 3.6G 145M 184K 276M 1.0G
-/+ buffers/cache: 2.3G 1.4G
Swap: 4.0G 0B 4.0G
3.定时刷新内存状态 3秒刷新一次
$ free -h -s 3
total used free shared buffers cached
Mem: 3.7G 3.6G 144M 184K 276M 1.0G
-/+ buffers/cache: 2.3G 1.4G
Swap: 4.0G 0B 4.0G
total used free shared buffers cached
Mem: 3.7G 3.6G 144M 184K 276M 1.0G
-/+ buffers/cache: 2.3G 1.4G
Swap: 4.0G 0B 4.0G
total used free shared buffers cached
Mem: 3.7G 3.6G 144M 184K 276M 1.0G
-/+ buffers/cache: 2.3G 1.4G
Swap: 4.0G 0B 4.0G
网友评论