Linux下磁盘管理命令df与du 

对磁盘进行查看和控制的两个linux命令,df和du。 
一、du命令 
首先看一下du的help说明:

  1. [root@misdwh opt]# du --help
  2. Usage: du [OPTION]... [FILE]...
  3. or:  du [OPTION]... --files0-from=F
  4. Summarize disk usage of each FILE, recursively for directories.
  5. Mandatory arguments to long options are mandatory for short options too.
  6. -a, --all             write counts for all files, not just directories
  7. --apparent-size   print apparent sizes, rather than disk usage; although
  8. the apparent size is usually smaller, it may be
  9. larger due to holes in ('sparse') files, internal
  10. fragmentation, indirect blocks, and the like
  11. -B, --block-size=SIZE use SIZE-byte blocks
  12. -b, --bytes           equivalent to `--apparent-size --block-size=1'
  13. -c, --total           produce a grand total
  14. -D, --dereference-args  dereference FILEs that are symbolic links
  15. --files0-from=F   summarize disk usage of the NUL-terminated file
  16. names specified in file F
  17. -H                    like --si, but also evokes a warning; will soon
  18. change to be equivalent to --dereference-args (-D)
  19. -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  20. --si              like -h, but use powers of 1000 not 1024
  21. -k                    like --block-size=1K
  22. -l, --count-links     count sizes many times if hard linked
  23. -m                    like --block-size=1M
  24. -L, --dereference     dereference all symbolic links
  25. -P, --no-dereference  don't follow any symbolic links (this is the default)
  26. -0, --null            end each output line with 0 byte rather than newline
  27. -S, --separate-dirs   do not include size of subdirectories
  28. -s, --summarize       display only a total for each argument
  29. -x, --one-file-system  skip directories on different file systems
  30. -X FILE, --exclude-from=FILE  Exclude files that match any pattern in FILE.
  31. --exclude=PATTERN Exclude files that match PATTERN.
  32. --max-depth=N     print the total for a directory (or file, with --all)
  33. only if it is N or fewer levels below the command
  34. line argument;  --max-depth=0 is the same as
  35. --summarize
  36. --time            show time of the last modification of any file in the
  37. directory, or any of its subdirectories
  38. --time=WORD       show time as WORD instead of modification time:
  39. atime, access, use, ctime or status
  40. --time-style=STYLE show times using style STYLE:
  41. full-iso, long-iso, iso, +FORMAT
  42. FORMAT is interpreted like `date'
  43. --help     display this help and exit
  44. --version  output version information and exit
  45. SIZE may be (or may be an integer optionally followed by) one of following:
  46. kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

语法:du [ -a | -s ] [ -k ] [ -m ] [ -g ][ -l ] [ -r ] [ -x ] [ -H | -L ][ File ... ]

描述:du命令显示用于文件的块数量。如果指定的File参数实际上是一个目录,就要报告该目录内的所有文件。如果没有提供File参数,du命令使用当前目录内的文件。 如果File参数是一个目录,那么报告的块的数量就是分配到目录中文件以及分配到目录自身的块之和。

指定-a标志:报告个体文件中块数量。不管是否使用了-a标志,由File参数指定的个体文件总是要列出。 
指定-s标志:报告用于所有指定文件和目录中所有文件的全部块。

分类解说一下各个参数的含义:

  1. -a 显示文件夹中的所有文件夹、文件的大小。默认只显示文件夹大小,不显示文件。
  2. -B 以xxByte为单位显示块数(默认为1024)
  3. -b 以1Byte为单位显示块数(但貌似与-B1的结果不同)
  4. -c 最后显示一行汇总数据
  5. -h 以方便阅读的方式展现大小(是以1000为单位,而非1024)
  6. -k 用 1024 字节单位计算块数,而不是用缺省的 512 字节单位。
  7. -m 用 MB 单位计算块数,而不是用缺省的 512 字节单位。
  8. -0 注意是数字“0”,而非字母“O”。表示每行后面不换行,直接跟下去
  9. -S 外层的文件夹大小不包含内层大小
  10. -s 只显示整个对象文件夹的合计大小。将该标志与-a标志进行对比。
  11. -x 在评估文件大小时,只评估那些与File参数指定的文件或者目录驻留在相同设备上的文件。

注:

  1. 1、具有多个链接的文件只为一个条目计数和书写。
  2. 2、由于块计数只基于文件大小,所以在报告的块数中,未分配的块是没有包含进去的。
  3. 3、如果du得不到文件属性,或者无法读取目录,它就报告一个错误,并且会影响命令的退出状态。
  4. 4、如果同时指定-k、-m标志,则后面的那个起作用。且输出结果四舍五入。

退出状态:

此命令返回下列出口值: 
=0 成功结束。 
>0 发生错误。

二、df命令

  1. [root@misdwh devMISowb]# df --help
  2. Usage: df [OPTION]... [FILE]...
  3. Show information about the file system on which each FILE resides,
  4. or all file systems by default.
  5. Mandatory arguments to long options are mandatory for short options too.
  6. -a, --all             include dummy file systems
  7. -B, --block-size=SIZE use SIZE-byte blocks
  8. -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  9. -H, --si              likewise, but use powers of 1000 not 1024
  10. -i, --inodes          list inode information instead of block usage
  11. -k                    like --block-size=1K
  12. -l, --local           limit listing to local file systems
  13. --no-sync         do not invoke sync before getting usage info (default)
  14. -P, --portability     use the POSIX output format
  15. --sync            invoke sync before getting usage info
  16. -t, --type=TYPE       limit listing to file systems of type TYPE
  17. -T, --print-type      print file system type
  18. -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  19. -v                    (ignored)
  20. --help     display this help and exit
  21. --version  output version information and exit
  22. SIZE may be (or may be an integer optionally followed by) one of following:
  23. kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

df命令可显示所有文件系统对i节点和磁盘块的使用情况。

各个选项的含义如下:

  1. -a 显示所有文件系统的磁盘使用情况,包括0块(block)的文件系统,如/proc文件系统。
  2. -B 以xxByte为单位显示块数(默认为1024)
  3. -h 以方便阅读的方式展现大小(是以1024为单位)
  4. -H 以方便阅读的方式展现大小(是以1000为单位)
  5. -i 显示i节点信息,而不是磁盘块。
  6. -k 以k字节为单位显示。
  7. -P 以POSIX格式输出结果(不换行?)
  8. -t 后面跟“=type类型”,显示各指定类型的文件系统的磁盘空间使用情况。
  9. -T 显示文件系统类型。
  10. -x 后面跟“=type类型”,列出不是某一指定类型文件系统的磁盘空间使用情况(与t选项相反)。

显示内容说明:

  1. $ df
  2. Filesystem 1K-blocks   Used  Available Use% Mounted on
  3. /dev/hda2  1361587   1246406      44823 97% /

df命令的输出清单的第1列是代表文件系统对应的设备文件的路径名( 一般是硬盘上的分区);第2列给出分区包含的数据块(1024字节)的数目;第3、4列分别表示已用的和可用的数据块数目。用户也许会感到奇怪的是:第3、4列块数之和不等于第2列中的块数。这是因为缺省的每个分区都留了少量空间供系统管理员使用。即使遇到普通用户空间已满的情况,管理员仍能登录和留有解决问题所需的工作空间。清单中Use%列表示普通用户空间使用的百分比,即使这一数字达到100%,分区仍然留有系统管理员使用的空间。最后,Mounted on列表示文件系统的安装点。

本文原始链接:http://www.jbxue.com/LINUXjishu/1603.html

Linux下磁盘管理命令df与du的更多相关文章

  1. centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课

    centos Linux下磁盘管理   parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...

  2. Linux文件系统管理 常见命令df、du、fsck、dumpe2fs

    概述 Linux文件系统管理 常见命令df.du.fsck.dumpe2fs. 文件系统查看命令:df 通过 df 命令可以査看已经挂载的文件系统的信息包括设备文件名.文件系统总大小.已经使用的大小. ...

  3. linux下磁盘管理(du、df)命令使用

    DF :disk free 磁盘可用量 DU: disk usage 磁盘使用 df:列出文件系统的整体磁盘使用量: df参数: -a:列出所有的文件系统,包括系统特有的/proc等文件系统 -k:以 ...

  4. linux系统--磁盘管理命令(一)

    一.基本命令 1.1 查看磁盘分区使用状况:df 参数: l:仅显示本地磁盘(默认) a:显示所有文件系统的磁盘使用情况,包括比如 /proc/ h:以1024进制计算最合适的单位显示磁盘容量 H:以 ...

  5. linux下用户管理命令、用户组管理命令

    useradd 添加新用户 1.基本语法 useradd 用户名                   (功能描述:添加新用户) useradd -g 组名 用户名      (功能描述:添加新用户到某 ...

  6. lesson - 6 Linux下磁盘管理

    1. 查看磁盘或者目录的容量df  查看磁盘各分区使用情况   不加参数以k为单位   df -i inode数,df -h  以G或者T或者M   df -m  以M单位显示  du 查看目录或者文 ...

  7. Linux下磁盘管理

    设置密码mkpasswdmkpasswd -s 0mkpasswd -s 0 -1 15 规定密码的长度 1. 查看磁盘或者目录的容量df 查看磁盘各分区使用情况 不加参数以k为单位 df -i in ...

  8. linux系统--磁盘管理命令(二)

    一.硬盘的分区模式 之前的硬盘分区模式为MBR 主分区不超过4个 单个分区容量最大为2TB 前面的分区模式就为MBR分区模式. 另一种分区模式为GPT 主分区个数限制:在GPT的分区表中最多可以支持1 ...

  9. linux常用命令之--磁盘管理命令

    linux的磁盘管理命令 1.查看磁盘空间 df:用于显示磁盘空间的使用情况 其命令格式如下: df [-option] 常用参数: -i:使用inodes显示结果 -k:使用KBytes显示结果 - ...

随机推荐

  1. EatCam Webcam Recorder Pro

    EatCam Webcam Recorder Pro Webcam Recorder records webcams to AVI, FLV, WMV files and watch them whe ...

  2. MySQL数据库的概念

    学习数据库的一些知识.写写博客方便梳理以及巩固知识. 关于什么是数据库就举一个样例来说明,说的可能不够准确,仅仅要明确一个大概的意思就够了.深刻的学习还是要去看书的. 讲讲生活中有关数据的样例:在一个 ...

  3. Android onConfigurationChanged 不执行

    自从Android 3.2(API 13),screen size也开始跟着设备的横竖切换而改变. 所以,在AndroidManifest.xml里设置的MiniSdkVersion和 TargetS ...

  4. 总结学习 Python 的 14 张思维导图汇总

  5. Linux进程间通信—信号

    三.信号(Signal) 信号是Unix系统中使用的最古老的进程间通信的方法之一.操作系统通过信号来通知某一进程发生了某一种预定好的事件:接收到信号的进程可以选择不同的方式处理该信号,一是可以采用默认 ...

  6. sqllite3

    OS X自从10.4后把SQLite这套相当出名的数据库软件,放进了作业系统工具集里.OS X包装的是第三版的SQLite,又称SQLite3.这套软件有几个特色: 软件属于公共财(public do ...

  7. Android两次后退键退出

    转载请注明出处:http://blog.csdn.net/javacattle/article/details/41964045 仅仅要在 *.Java 文件里加入就可以 private int ba ...

  8. Jenkins 安装与使用--实例

    參考了博客Jenkins master在windows上安装 Jenkins的主要功能是监视反复工作的运行,比如软件project的构建详细地: *软件的持续构建和測试 本质上提供了一个易于使用的持续 ...

  9. Minimum edit distance(levenshtein distance)(最小编辑距离)初探

    最小编辑距离的定义:编辑距离(Edit Distance),又称Levenshtein距离.是指两个字串之间,由一个转成还有一个所需的最少编辑操作次数.许可的编辑操作包含将一个字符替换成还有一个字符. ...

  10. 算法笔记_131:出现次数超过一半的数(Java)

    目录 1 问题描述 2 解决方案 2.1 每次删除两个不同的数 2.2 记录两个值   1 问题描述 数组中有一个数出现的次数超过了数组长度的一半,请找出这个数. 2 解决方案 2.1 每次删除两个不 ...