您的当前位置:首页正文

linux查看文件大小df-du

来源:九壹网

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、查看该文件夹的总大小

[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

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

[root@rhel7 /]# du -sh /usr  
803M    /usr
[root@rhel7 /]# du -ch /usr/    --递归目录里所有文件,列出大小,最后总和。
......
4.0K    /usr/libexec/os-probes/init
8.0K    /usr/libexec/os-probes/mounted/efi
68K     /usr/libexec/os-probes/mounted
80K     /usr/libexec/os-probes
24K     /usr/libexec/plymouth
0       /usr/libexec/tuned
32K     /usr/libexec/man-db
8.2M    /usr/libexec/postfix
12M     /usr/libexec
0       /usr/local/bin
0       /usr/local/etc
0       /usr/local/games
0       /usr/local/include
0       /usr/local/lib
0       /usr/local/lib64
0       /usr/local/libexec
0       /usr/local/sbin
0       /usr/local/share/applications
0       /usr/local/share/info
0       /usr/local/share/man/man1
0       /usr/local/share/man/man1x
0       /usr/local/share/man/man2
0       /usr/local/share/man/man2x
0       /usr/local/share/man/man3
0       /usr/local/share/man/man3x
0       /usr/local/share/man/man4
0       /usr/local/share/man/man4x
0       /usr/local/share/man/man5
0       /usr/local/share/man/man5x
0       /usr/local/share/man/man6
0       /usr/local/share/man/man6x
0       /usr/local/share/man/man7
0       /usr/local/share/man/man7x
0       /usr/local/share/man/man8
0       /usr/local/share/man/man8x
0       /usr/local/share/man/man9
0       /usr/local/share/man/man9x
0       /usr/local/share/man/mann
4.0K    /usr/local/share/man
4.0K    /usr/local/share
0       /usr/local/src
8.0K    /usr/local
0       /usr/src/debug
0       /usr/src/kernels
0       /usr/src
803M    /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/bin
38M     /usr/sbin
372M    /usr/lib
123M    /usr/lib64
202M    /usr/share
0       /usr/etc
0       /usr/games
5.3M    /usr/include
12M     /usr/libexec
8.0K    /usr/local
0       /usr/src
803M    /usr/
[root@rhel7 /]# 

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Top