linux命令学习2-du

du的英文原义为“disk usage”,含义为显示磁盘空间的使用情况。

 

几个使用点or注意点:

1. 相比于ls, du的优点是可以递归地检索所有子文件夹下的文件

du -sh *   查看当前目录下的文件夹和文件的大小

 

2.du -sh * | sort -n

可以迅速发现那个目录是最大的。

 

3. du和df区别

        du和df命令都被用于获得文件系统大小的信息:df用于报告文件系统的总块数及剩余块数,du -s /<filesystem>用于报告文件系统使用的块数。但是,我们可以发现从df命令算出的文件系统使用块数的值与通过du命令得出的值是不一致的。

        该值差异的存在是由于du与df命令实施上的不同: du -s命令通过将指定文件系统中所有的目录、符号链接和文件使用的块数累加得到该文件系统使用的总块数;而df命令通过查看文件系统磁盘块分配图得出总块数与剩余块数。
  文件系统分配其中的一些磁盘块用来记录它自身的一些数据,如i节点,磁盘分布图,间接块,超级块等。这些数据对大多数用户级的程序来说是不可见的,通常称为Meta Data。
  du命令是用户级的程序,它不考虑Meta Data,而df命令则查看文件系统的磁盘分配图并考虑Meta Data。df命令获得真正的文件系统数据,而du命令只查看文件系统的部分情况。

 

 

4. --help看细节:

  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in (`sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  use SIZE-byte blocks
  -b, --bytes           equivalent to `--apparent-size --block-size=1'
  -c, --total           produce a grand total 最后再加上一个总计(系统缺省设置)
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
      --files0-from=F   summarize disk usage of the NUL-terminated file
                          names specified in file F;
                          If F is - then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --si              like -h, but use powers of 1000 not 1024

  -k                    like --block-size=1K
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -L, --dereference     dereference all symbolic links
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -0, --null            end each output line with 0 byte rather than newline
  -S, --separate-dirs   do not include size of subdirectories
  -s, --summarize       display only a total for each argument

  -x, --one-file-system    skip directories on different file systems
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
      --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize

      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using style STYLE:
                          full-iso, long-iso, iso, +FORMAT
                          FORMAT is interpreted like `date'
      --help     display this help and exit
      --version  output version information and exit

 

参考引用:

1. du和df

http://www.linuxpk.com/151.html

2. linux磁盘管理命令--du(这个资料太老了)

http://fanqiang.chinaunix.net/a1/b5/20010508/132803.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值