• Linux命令(103)之du


    linux命令之du

    1.du介绍

    linux命令du是命令用来查看目录或文件所占用磁盘空间的大小

    2.du用法

    du [参数] filename|dirname

    du常用参数
    参数说明
    -h以人类可读的方式显示
    -s显示目录占用的磁盘空间大小,不要显示其下子目录和文件占用的磁盘空间大小
    -k以1024 bytes为单位
    -m以1024 bytes为单位
    -l(消息L)统计硬链接占用磁盘空间的大小
    -L统计符号链接所指向的文件占用的磁盘空间大小
    --max-depth=NN是数值,表示目录层数,超过指定层数的目录后,予以忽略

    3.实例

    3.1.以人类可读的方式(K/M/G)显示/etc目录的大小

    命令:

    du -sh /etc

    1. [root@rhel77 ~]# du -sh /etc
    2. 66M /etc
    3. [root@rhel77 ~]#

    3.2.统计硬链接占用磁盘空间的大小

    命令:

    du -l /root

    1. [root@rhel77 ~]# du -l /root
    2. 0 /root/110
    3. 12 /root/.ssh
    4. 0 /root/111
    5. 0 /root/3
    6. 4 /root/.oracle_jre_usage
    7. 16 /root/test
    8. 0 /root/back
    9. 4 /root/.cache/abrt
    10. 4 /root/.cache
    11. 0 /root/.config/abrt
    12. 0 /root/.config/gconf
    13. 4 /root/.config/dconf
    14. 0 /root/.config/ibus/bus
    15. 0 /root/.config/ibus
    16. 4 /root/.config
    17. 0 /root/4
    18. 4 /root/ztj/test
    19. 16 /root/ztj
    20. 16 /root/2
    21. 8 /root/.dbus/session-bus
    22. 8 /root/.dbus
    23. 0 /root/.emacs.d
    24. 4 /root/z
    25. 28 /root/1
    26. 112 /root/extundelete-0.2.4/src/.deps
    27. 4780 /root/extundelete-0.2.4/src
    28. 5244 /root/extundelete-0.2.4
    29. 0 /root/z1
    30. 16 /root/ztj11
    31. 0 /root/testdir
    32. 0 /root/.ansible/tmp
    33. 0 /root/.ansible
    34. 0 /root/.pki/nssdb
    35. 0 /root/.pki
    36. 635976 /root
    37. [root@rhel77 ~]#

    3.3.统计符号链接所指向的文件占用的磁盘空间大小

    命令:

    du -L /root

    1. [root@rhel77 .pki]# du -L /root
    2. 0 /root/110
    3. 12 /root/.ssh
    4. 0 /root/111
    5. 0 /root/3
    6. 4 /root/.oracle_jre_usage
    7. 8 /root/test
    8. 0 /root/back
    9. 4 /root/.cache/abrt
    10. 4 /root/.cache
    11. 112 /root/extundelete/src/.deps
    12. 4780 /root/extundelete/src
    13. 5244 /root/extundelete
    14. 0 /root/.config/abrt
    15. 0 /root/.config/gconf
    16. 4 /root/.config/dconf
    17. 0 /root/.config/ibus/bus
    18. 0 /root/.config/ibus
    19. 4 /root/.config
    20. 0 /root/4
    21. 4 /root/ztj/test
    22. 16 /root/ztj
    23. 16 /root/2
    24. 8 /root/.dbus/session-bus
    25. 8 /root/.dbus
    26. 0 /root/.emacs.d
    27. 4 /root/z
    28. 28 /root/1
    29. 0 /root/z1
    30. 16 /root/ztj11
    31. 0 /root/testdir
    32. 0 /root/.ansible/tmp
    33. 0 /root/.ansible
    34. 0 /root/.pki/nssdb
    35. 0 /root/.pki
    36. 635968 /root
    37. [root@rhel77 .pki]#

    3.4.查看etc目录及下一级子文件和子目录占用的磁盘容量,并排序

    命令:

    du -lh  /etc --max-depth=1 | sort -nr

    1. [root@rhel77 ~]# du -lh /etc --max-depth=1 | sort -nr
    2. 604K /etc/ssh
    3. 456K /etc/sysconfig
    4. 380K /etc/lvm
    5. 332K /etc/sane.d
    6. 292K /etc/xdg
    7. 244K /etc/vmware-tools
    8. 236K /etc/dbus-1
    9. 224K /etc/ImageMagick
    10. 196K /etc/mail
    11. 176K /etc/pam.d
    12. 172K /etc/libreport
    13. 156K /etc/libvirt
    14. 148K /etc/postfix
    15. 128K /etc/bash_completion.d
    16. 92K /etc/httpd
    17. 88K /etc/profile.d
    18. 84K /etc/security
    19. 80K /etc/speech-dispatcher
    20. 80K /etc/logrotate.d
    21. 72K /etc/grub.d
    22. 68K /etc/X11
    23. 68K /etc/openldap
    24. 66M /etc
    25. 60K /etc/setuptool.d
    26. 60K /etc/libibverbs.d
    27. 52K /etc/sound
    28. 52K /etc/rpm
    29. 52K /etc/ppp
    30. 48K /etc/rdma
    31. 48K /etc/rc.d
    32. 44K /etc/cups
    33. 40M /etc/selinux
    34. 36K /etc/systemd
    35. 36K /etc/iproute2
    36. 32K /etc/yum.repos.d
    37. 32K /etc/yum
    38. 32K /etc/php.d
    39. 32K /etc/dconf
    40. 32K /etc/abrt
    41. 28K /etc/rhsm
    42. 28K /etc/nginx
    43. 28K /etc/NetworkManager
    44. 28K /etc/modprobe.d
    45. 24K /etc/unbound
    46. 24K /etc/mcelog
    47. 24K /etc/ipsec.d
    48. 24K /etc/fwupd
    49. 24K /etc/fonts
    50. 20K /etc/samba
    51. 20K /etc/pulse
    52. 20K /etc/ld.so.conf.d
    53. 20K /etc/java
    54. 20K /etc/iscsi
    55. 20K /etc/gdm
    56. 16K /etc/tuned
    57. 16K /etc/smartmontools
    58. 16K /etc/skel
    59. 16K /etc/sasl2
    60. 16K /etc/prelink.conf.d
    61. 16K /etc/PackageKit
    62. 16K /etc/firewalld
    63. 16K /etc/cron.daily
    64. 16K /etc/audit
    65. 16K /etc/audisp
    66. 12K /etc/gssproxy
    67. 12K /etc/default
    68. 12K /etc/cupshelpers
    69. 12K /etc/cron.d
    70. 12K /etc/avahi
    71. 12K /etc/alsa
    72. 8.0K /etc/setroubleshoot
    73. 8.0K /etc/rwtab.d
    74. 8.0K /etc/ras
    75. 8.0K /etc/polkit-1
    76. 8.0K /etc/oddjobd.conf.d
    77. 8.0K /etc/ntp
    78. 8.0K /etc/ndctl
    79. 8.0K /etc/lsm
    80. 8.0K /etc/libnl
    81. 8.0K /etc/groff
    82. 8.0K /etc/gnome-vfs-2.0
    83. 8.0K /etc/festival
    84. 8.0K /etc/dnf
    85. 8.0K /etc/dhcp
    86. 8.0K /etc/depmod.d
    87. 8.0K /etc/cron.hourly
    88. 7.9M /etc/udev
    89. 6.2M /etc/gconf
    90. 4.0K /etc/xml
    91. 4.0K /etc/wpa_supplicant
    92. 4.0K /etc/UPower
    93. 4.0K /etc/udisks2
    94. 4.0K /etc/sgml
    95. 4.0K /etc/rsyslog.d
    96. 4.0K /etc/request-key.d
    97. 4.0K /etc/qemu-kvm
    98. 4.0K /etc/qemu-ga
    99. 4.0K /etc/python
    100. 4.0K /etc/purple
    101. 4.0K /etc/plymouth
    102. 4.0K /etc/opt
    103. 4.0K /etc/libblockdev
    104. 4.0K /etc/kernel
    105. 4.0K /etc/hp
    106. 4.0K /etc/gss
    107. 4.0K /etc/geoclue
    108. 4.0K /etc/fcoe
    109. 4.0K /etc/dracut.conf.d
    110. 4.0K /etc/docker
    111. 4.0K /etc/chromium
    112. 4.0K /etc/bonobo-activation
    113. 4.0K /etc/bluetooth
    114. 4.0K /etc/alternatives
    115. 3.8M /etc/brltty
    116. 1.1M /etc/pki
    117. 0 /etc/xinetd.d
    118. 0 /etc/tmpfiles.d
    119. 0 /etc/terminfo
    120. 0 /etc/sysctl.d
    121. 0 /etc/sudoers.d
    122. 0 /etc/statetab.d
    123. 0 /etc/ssl
    124. 0 /etc/smrsh
    125. 0 /etc/scl
    126. 0 /etc/popt.d
    127. 0 /etc/pm
    128. 0 /etc/pkcs11
    129. 0 /etc/oddjob
    130. 0 /etc/my.cnf.d
    131. 0 /etc/multipath
    132. 0 /etc/modules-load.d
    133. 0 /etc/maven
    134. 0 /etc/libpaper.d
    135. 0 /etc/krb5.conf.d
    136. 0 /etc/jvm-commmon
    137. 0 /etc/jvm
    138. 0 /etc/gnupg
    139. 0 /etc/glvnd
    140. 0 /etc/ghostscript
    141. 0 /etc/gdbinit.d
    142. 0 /etc/gcrypt
    143. 0 /etc/flatpak
    144. 0 /etc/firefox
    145. 0 /etc/exports.d
    146. 0 /etc/egl
    147. 0 /etc/dnsmasq.d
    148. 0 /etc/cron.weekly
    149. 0 /etc/cron.monthly
    150. 0 /etc/cifs-utils
    151. 0 /etc/chkconfig.d
    152. 0 /etc/binfmt.d
    153. [root@rhel77 ~]#
  • 相关阅读:
    Android原生插件开发-Parameters篇
    【SpringBoot笔记27】SpringBoot集成ES数据库之操作index索引(创建、删除、获取)
    为什么需要工业物联网 (IIoT)?如何实施?
    Linux 线程池&单例模式&读写锁&自旋锁
    这个面试官真烦,问完合并又问拆分。
    奖励函数是平稳的是什么意思
    线索二叉树与Morris遍历
    [杂记]关于C++中友元的一些理解
    C++PrimerPlus 第六章 分支语句和逻辑运算符(复习题含答案)
    短视频时代,亚马逊产品视频的作用是什么?对于提升Listing转化率究竟有何好处?
  • 原文地址:https://blog.csdn.net/z19861216/article/details/133919985