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

linux查看文件大小df-du的更多相关文章

  1. Linux查看文件大小命令

    Linux查看文件大小命令 du命令 (1)du -b filepath 参数-b表示以字节计数 du -b filepath 参数-b表示以字节计数 #示例: $ du -b ~/Downloads ...

  2. Linux查看文件大小5个常用命令

    1. 前言 Linux 系统有非常好用的命令,功能也非常丰富,如果你对命令行工具熟悉,可以非常高效率完成维护工具.本文主要介绍Linux系统中,用于查看文件大小的命令. Linux 查看文件大小5个常 ...

  3. 【linux】linux查看文件大小,磁盘大小

    查看指定目录下 文件或目录大小超过多少的 查看 /backup/tomcat7/ 目录下 超过500M大小的文件 并展示 文件详情 find /backup/tomcat7/  -type f -si ...

  4. linux 查看磁盘、文件夹、文件大小(df du)

    du 查看文件夹大小 1.查看当前文件夹中所有文件夹及其子文件夹的大小,注意是文件夹大小,不是文件 # du -h -rw-r--r-- 1 root root 82785865 6月 9 15:53 ...

  5. Linux编程 8 (挂载mount,查看磁盘df du,搜索grep,压缩zgip,归档tar)

    一. 挂载存储媒体 linux文件系统将所有的磁盘都并入一个虚拟目录下,当使用新的存储媒体之前,需要把它放到虚拟目录下,这项工作称为挂载(mounting) 1.1 mount 命令 在linux上用 ...

  6. Linux 查看文件大小并按照大小排序

    使用df 命令查看当前系统磁盘的使用情况: [root@node ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/map ...

  7. Linux查看文件大小

    //查看系统中文件的使用情况 df -h //查看当前目录下各个文件及目录占用空间大小 du -sh * //查看welcome.txt文件占用空间大小 du -sh welcome.txt //方法 ...

  8. Unix/Linux 查看文件大小

    ls -l help.html-rw-r--r--  1 william  wheel  40960 Jul 18 00:59 development.sqlite3 40960 就是文件的大小. d ...

  9. Linux 常用命令——df, du, ln

    1. df 列出文件系统的整体磁盘使用量 2. du 评估文件系统的磁盘使用量(常用在推估目录所占容量),也可以计算文件或文件夹大小 3. ln 创建实体连接(hard link) 或 符号连接(Sy ...

随机推荐

  1. 安装VS2010后,如何设置老版本的项目文件不是默认用VS2010打开

    1.系统先后安装了VS2008和VS2010,在打开用VS2008创建的项目文件时总是会默认用VS2010打开,选择打开方式都不行,很不方便,差点要把VS2010卸载了.     其实只需要简单设置V ...

  2. python的exec、eval详解

    exec exec语句用来执行储存在字符串或文件中的Python语句.例如,我们可以在运行时生成一个包含Python代码的字符串,然后使用exec语句执行这些语句.下面是一个简单的例子. exec ' ...

  3. PHP set_error_handler() 函数

    定义和用法 set_error_handler() 函数设置用户自定义的错误处理函数. 该函数用于创建运行时期间的用户自己的错误处理方法. 该函数会返回旧的错误处理程序,若失败,则返回 null. 语 ...

  4. 自定义异常throw

    简单自定义一个年龄小于等于0,或者大于120会出现的异常 首先继承父类Exception,调用父类的构造器,这样才可以报出自己想要的异常 public class AgeException exten ...

  5. 思科27亿美元收购网络安全公司Sourcefire

    据国外媒体报道,思科于今日宣布将以27亿美元的总价收购网络安全公司Sourcefire,以加强自身在网络安全业务领域的优势,该交易将于今年下半年完成. [IT商业新闻网讯](记者 张良)7月23日消息 ...

  6. MySQL索引和锁

    索引和锁可以让查询锁定更少的行.如果你的查询从不访问那些不需要访问的行,那么就会锁定更少的行,从两个方面来看这对性能都有好处.首先,虽然innodb的行锁效率很高,内存使用也很少,但是锁定行的时候仍然 ...

  7. spring boot了解

    spring4倾向于基于注解的配置,强化的注解的功能,对比与spring3还是有很多的区别:spring boot对spring的各个组件功能管理,基于默认配置即可简单构建一个spring4的项目,对 ...

  8. php 操作xml文件

    读取xml:$doc=new DOMDocument(); $doc->load('news.xml'); $news=$doc->getElementsByTagName("n ...

  9. phpcms v9 表单向导里添加图片字段,提示会话过期,请重新登陆

    用 phpcms v9 制作前端用户提交信息时,有个图片上传的栏目. 如果注释 /phpcms/modules/attachment/attachment.php 20//判断是否登录 21 if(e ...

  10. 在线编辑器kindEditor

    操作文档:http://kindeditor.net/doc.php 文件下载