磁盘情况查询
查询系统整体磁盘实用情况
- 基本语法
df -h - 应用实例
查询系统整体磁盘使用情况
查询指定目录的磁盘占用情况
- 基本语法
du -h /目录
查询指定目录的磁盘占用情况,默认为当前目录
-s 指定目录占用大小汇总
-h 带计量单位
-a 含文件
-max-depth=1 子目录深度
-c 列出明细的同时,增加汇总值 - 应用实例
查询/opt 目录的磁盘占用情况,深度为1
磁盘情况-工作实用指令
1)、统计/home文件夹下文件的个数
[root@localhost /]# ls -l /home/ | grep "^-" | wc -l
2)、统计/home文件夹下目标的个数
[root@localhost /]# ls -l /home/ | grep "^d" | wc -l
3)、统计/home文件夹下文件的个数,包括子文件夹里的
[root@localhost /]# ls -lR /home/ | grep "^-" | wc -l
4)、统计文件下目录的个数,包括子文件夹里的
[root@localhost /]# ls -lR /home/ | grep "^d" | wc -l
5)、以树状显示目录结构
[root@localhost /]# tree /home/
/home/
├── a1.txt
├── a2.txt
├── abc.txt
├── animal
│ └── tiger
├── apple.txt
├── a.tar.gz
├── fox
├── hello.txt
├── info.txt
├── jack
│ └── jack01.txt
├── jerry
├── kkk
│ ├── a.txt
│ └── b.txt
├── mycal
├── mydate.txt
├── myhome.tar.gz
├── mypackage.zip
├── mytask1.sh
├── newHello.txt
├── orange.txt
├── test
│ ├── a.txt
│ ├── b.txt
│ └── c.txt
├── tom
│ └── ok.txt
├── xh
├── xm
├── xq
└── zwj
└── test
├── a.txt
├── b.txt
└── c.txt