Linux 查看磁盘空间可以使用df和du命令。
df 以磁盘分区为单位查看文件系统,可以获取硬盘被占用了多少空间,目前还剩下多少空间等信息。
例如,我们使用df -h命令来查看磁盘信息,-h选项为根据大小适当显示:
显示内容参数说明:
相关命令:
du的英文原义为disk usage,含义为显示磁盘空间的使用情况,用于查看当前目录的总大小。
例如查看当前目录的大小:
- # du -sh
- 605M .
显示指定文件所占空间:
- # du log2012.log
- 300 log2012.log
方便阅读的格式显示test目录所占空间情况:
- # du -h test
- 608K test/test6
- 308K test/test4
- 4.0K test/scf/lib
- 4.0K test/scf/service/deploy/product
- 4.0K test/scf/service/deploy/info
- 12K test/scf/service/deploy
- 16K test/scf/service
- 4.0K test/scf/doc
- 4.0K test/scf/bin
- 32K test/scf
- 8.0K test/test3
- 1.3M test
du 命令用于查看当前目录的总大小: