博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux查看文件大小df-du
阅读量:7052 次
发布时间:2019-06-28

本文共 3238 字,大约阅读时间需要 10 分钟。

1、  显示目前所有文件系统的可用空间及使用情形,h表示使用 GB、MB 等易读的格式

[root@rusky ldap]# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 3.8G 1.9G 1.8G 51% /
/dev/sda1 46M 9.2M 35M 22% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/sda3 14G 2.5G 11G 19% /home
.host:/ 83G 38G 46G 45% /mnt/hgfs   ----这个是挂载的主机与vmware共享文件夹所在的分区情况

2、查看该文件夹的总大小

du -sh  查看当前目录大小,-s表示显示目录总大小,否则,列出该目录下所有子目录文件大小

[root@rusky ldap]# du -h --max-depth=0 apache-tomcat-6.0.37   或者直接进入该目录下,使用命令:du -sh即可查询

5.3M apache-tomcat-6.0.37

3、 显示bin目录的大小

[root@rusky ldap]# du -h --max-depth=0 apache-tomcat-6.0.37/bin

323K apache-tomcat-6.0.37/bin

4、显示apache-tomcat-6.0.37这个文件夹里各个文件或文件夹的大小

[root@rusky ldap]# du -h --max-depth=0 apache-tomcat-6.0.37/*

324K apache-tomcat-6.0.37/bin
100K apache-tomcat-6.0.37/conf
2.7M apache-tomcat-6.0.37/lib
19K apache-tomcat-6.0.37/LICENSE
0 apache-tomcat-6.0.37/logs
512 apache-tomcat-6.0.37/NOTICE
4.5K apache-tomcat-6.0.37/RELEASE-NOTES
8.5K apache-tomcat-6.0.37/RUNNING.txt
0 apache-tomcat-6.0.37/temp
2.2M apache-tomcat-6.0.37/webapps
0 apache-tomcat-6.0.37/work

5、查看单个文件的大小

[root@rusky bin]# du -h bootstrap.jar

12K bootstrap.jar

====================

du 用来查看某个目录所占空间大小

语法:du [-abckmsh] [文件或者目录名] 常用的参数有:
-a:全部文件与目录大小都列出来。如果不加任何选项和参数只列出目录(包含子目录)大小。
-b:列出的值以bytes为单位输出,默认是以Kbytes
-c:最后加总
-k:以KB为单位输出
-m:以MB为单位输出
-s:只列出总和
-h:系统自动调节单位,例如文件太小可能就几K,那么就以K为单位显示,如果大到几G,则就以G为单位显示。常用du –sh filename

[root@rhel7 /]# du -sh /usr  803M    /usr[root@rhel7 /]# du -ch /usr/    --递归目录里所有文件,列出大小,最后总和。......4.0K    /usr/libexec/os-probes/init8.0K    /usr/libexec/os-probes/mounted/efi68K     /usr/libexec/os-probes/mounted80K     /usr/libexec/os-probes24K     /usr/libexec/plymouth0       /usr/libexec/tuned32K     /usr/libexec/man-db8.2M    /usr/libexec/postfix12M     /usr/libexec0       /usr/local/bin0       /usr/local/etc0       /usr/local/games0       /usr/local/include0       /usr/local/lib0       /usr/local/lib640       /usr/local/libexec0       /usr/local/sbin0       /usr/local/share/applications0       /usr/local/share/info0       /usr/local/share/man/man10       /usr/local/share/man/man1x0       /usr/local/share/man/man20       /usr/local/share/man/man2x0       /usr/local/share/man/man30       /usr/local/share/man/man3x0       /usr/local/share/man/man40       /usr/local/share/man/man4x0       /usr/local/share/man/man50       /usr/local/share/man/man5x0       /usr/local/share/man/man60       /usr/local/share/man/man6x0       /usr/local/share/man/man70       /usr/local/share/man/man7x0       /usr/local/share/man/man80       /usr/local/share/man/man8x0       /usr/local/share/man/man90       /usr/local/share/man/man9x0       /usr/local/share/man/mann4.0K    /usr/local/share/man4.0K    /usr/local/share0       /usr/local/src8.0K    /usr/local0       /usr/src/debug0       /usr/src/kernels0       /usr/src803M    /usr/803M    total[root@rhel7 /]# du -h --max-depth=0 /usr/     ----该命令等同于:du -sh /usr  803M    /usr/[root@rhel7 /]# du -h --max-depth=1 /usr/     ---统计第1级目录的大小,最后也有总的大小54M     /usr/bin38M     /usr/sbin372M    /usr/lib123M    /usr/lib64202M    /usr/share0       /usr/etc0       /usr/games5.3M    /usr/include12M     /usr/libexec8.0K    /usr/local0       /usr/src803M    /usr/[root@rhel7 /]#

 

转载于:https://www.cnblogs.com/rusking/p/3629763.html

你可能感兴趣的文章
Jmeter(三)-简单的HTTP请求(非录制)
查看>>
linux查看系统类型和版本
查看>>
ThinkPHP将上传问件添加到数据库
查看>>
python 不同目录间的模块调用
查看>>
centos7 安装 chrome
查看>>
IOS 关于上传图片裁剪以及压缩,确保高清
查看>>
HDU - 6115 Factory (LCA 倍增)
查看>>
unity客户端与c++服务器之间的简单通讯_1
查看>>
Python_反射
查看>>
Codeforces-963 D Frequency of String
查看>>
MyBatis-mybatis全局映射文件解析
查看>>
WebApi 跨域解决方案 --CORS
查看>>
MySQL系列详解五: xtrabackup实现完全备份及增量备份详解-技术流ken
查看>>
单独编译Android源代码中的模块
查看>>
manjaro安装mysql5.7
查看>>
记录零散的知识点
查看>>
H5上传图片并使用canvas制作海报
查看>>
springmvc学习笔记
查看>>
LRU算法的设计
查看>>
Java util包中常用的类和方法
查看>>