linux du命令使用

一、用法

DU(1) User Commands DU(1)
NAME
       du - estimate file space usage
SYNOPSIS
       du [OPTION]... [FILE]...
       du [OPTION]... --files0-from=F
DESCRIPTION
       Summarize disk usage of each FILE, recursively for directories.
       Mandatory arguments to long options are mandatory for short options too.
       -0, --null
              end each output line with 0 byte rather than newline
       -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
              scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576
              bytes; see SIZE format below
       -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
       -d, --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
       --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)
       --inodes
              list inode usage information instead of block usage
       -k like --block-size=1K
       -L, --dereference
              dereference all symbolic links
       -l, --count-links
              count sizes many times if hard linked
       -m like --block-size=1M
       -P, --no-dereference
              don't follow any symbolic links (this is the default)
       -S, --separate-dirs
              for directories do not include size of subdirectories
       --si like -h, but use powers of 1000 not 1024
       -s, --summarize
              display only a total for each argument
       -t, --threshold=SIZE
              exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative
       --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, which can be: full-iso, long-iso, iso, or +FORMAT; FORMAT is inter‐
              preted like in 'date'
       -X, --exclude-from=FILE
              exclude files that match any pattern in FILE
       --exclude=PATTERN
              exclude files that match PATTERN
       -x, --one-file-system
              skip directories on different file systems
       --help display this help and exit
       --version
              output version information and exit
       Display values are in units of the first available SIZE from --block-size, and the DU_BLOCK_SIZE,
       BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if
       POSIXLY_CORRECT is set).
       SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z,
       Y (powers of 1024) or KB, MB, ... (powers of 1000).
       GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report du translation bugs to
       <http://translationproject.org/team/>
PATTERNS
       PATTERN is a shell pattern (not a regular expression). The pattern ? matches any one character,
       whereas * matches any string (composed of zero, one or multiple characters). For example, *.o will
       match any files whose names end in .o. Therefore, the command
              du --exclude='*.o'
       will skip all files and subdirectories ending in .o (including the file .o itself).
AUTHOR
       Written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering.
COPYRIGHT
       Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
       <http://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the
       extent permitted by law.
SEE ALSO
       The full documentation for du is maintained as a Texinfo manual. If the info and du programs are
       properly installed at your site, the command
              info coreutils 'du invocation'
       should give you access to the complete manual.
GNU coreutils 8.22 April 2018 DU(1)

二、使用情况

当系统磁盘块满了的时候,就要用到du命令查看是哪个日志文件占用量过大。

三、命令使用

只需掌握du -sh即可

[root@t3 python]# ls                        ####python目录下有两个文件夹
1 2
[root@t3 python]# du -sh 1             ####查看文件夹1的总占用量
28K    1
[root@t3 python]# du -sh 2             ####查看文件夹2的总占用量
76K    2
[root@t3 python]# du -sh                ####查看当前文件夹的总占用量
104K    .
[root@t3 python]#

四、实际应用

接收到了zabbix报警:Free disk space is less than 10% on volume /

查看报警图表

检查磁盘占用(df -h)

/目录下磁盘爆满

查找日志(du -sh)

logstash日志文件占用4.5G

清除保留5天

设置定时任务cut_logstash_log

清除elk30天前索引

设置定时任务month_ago_delete.sh

再次查看

检测到日志储存大小正常

编写定时任务,保留最近一周的统计日志

week_ago_delete.sh

处理结果:

磁盘恢复正常

linux du命令使用相关推荐

  1. Linux du 命令

    Linux du 命令 [ 解释 ] du 命令与 df 命令不同, du 命令是查看对文件和目录的磁盘使用情况. [ 常见参数 ]   du  -s   -- 仅显示总计,最后列出加总的值 -h   ...

  2. linux按照目录大小降序排列,Linux du命令查看文件夹大小并按降序排列

    1. df -lh 2. du -s /usr/* | sort -rn 这是按字节排序 3. du -sh /usr/* | sort -rn 这是按兆(M)来排序 4.选出排在前面的10个 du ...

  3. linux du命令 前多少个,Linux du命令查看文件夹大小并按降序排列

    1. df -lh 2. du -s /usr/* | sort -rn 这是按字节排序 3. du -sh /usr/* | sort -rn 这是按兆(M)来排序 4.选出排在前面的10个 du ...

  4. android shell du,Linux du 命令 command not found du 命令详解 du 命令未找到 du 命令安装 - CommandNotFound ⚡️ 坑否...

    显示行号 | 选择喜欢的代码风格 默认 GitHub Dune LakeSide Plateau Vibrant Blue Eighties Tranquil du 命令显示每个文件和目录的磁盘使用空 ...

  5. linux du命令,du命令示例

    Linux中的du命令也是查看使用空间的,与df命令不同的是,Linux du命令是对文件和目录磁盘使用的空间的查看,所以它和df命令还是有一些区别的. 1.命令格式du [选项][文件] 2.命令功 ...

  6. 【linux命令】Linux du 命令(显示目录或文件的大小)

    文章目录 1. Linux du 命令 2. 语法: 3. 实例 3.1 显示目录或者文件所占空间 3.2 显示指定文件所占空间 3.3 方便阅读的格式显示test目录所占空间情况 3.3.1 列出超 ...

  7. linux du命令重定向,df命令、du命令 、磁盘分区

    9月25日任务 4.1 df命令 4.2 du命令 4.3/4.4 磁盘分区 4.1.命令 :df    #磁盘空间使用情况 [root@zgxlinux-02 ~]# df 按字节显示 1000By ...

  8. 【Linux】一步一步学Linux——du命令(78)

    00. 目录 文章目录 00. 目录 01. 命令概述 02. 命令格式 03. 常用选项 04. 参考示例 05. 附录 01. 命令概述 du - 报告磁盘空间使用情况 du命令**的英文全称是& ...

  9. Linux du命令和df命令区别

    1,两者区别 du,disk usage,是通过搜索文件来计算每个文件的大小然后累加,du能看到的文件只是一些当前存在的,没有被删除的.他计算的大小就是当前他认为存在的所有文件大小的累加和. df,d ...

  10. linux du 命令详解

    du常见命令参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 3 ...

最新文章

  1. Python编写爬虫编写到Excel中
  2. Java并发编程的艺术(二)——重排序
  3. shiro spring boot thymeleaf
  4. Win-MASM64汇编语言-DUP/TIMES
  5. imagemagick, imagick和magickwand的安装
  6. 趣学 C 语言(十二)—— 文件操作
  7. Centos删除virbr0网卡
  8. ps计算机设置,ps标尺怎么调出来
  9. 【电驱动】驱动电机系统讲解
  10. JavaScript小纸条
  11. java pointer_Java EE 8 JSON Pointer讲解
  12. php 微信公众号图片外链,如何制作微信图文链接?微信图文链接生成
  13. deepin 安装到移动硬盘_系统装机|硬盘里的Linux之deepin 20系统安装教程
  14. 树莓派4B最新系统bullseye更换国内源方法
  15. Flutter无限循环滑动的PageView
  16. (13)TranslateMessage函数
  17. MIPI CSI和DSI接口标准简介
  18. 电脑硬件相关简单知识
  19. 无线网络技术教程(第3版)--原理、应用与实验 金光江光亮 编著 复习资料 聊城大学考试题目
  20. vue 首页白屏优化

热门文章

  1. hive-使用开窗函数实现百分比、topN、前百分比
  2. speedoffice(PPT)怎么将背景设置为渐变的背景
  3. 学习机器学习总体感受
  4. 对圆柱面的曲面积分_圆柱体的对面积的曲面积分
  5. OpenCV对图像像素尺寸的设置
  6. c语言程序求200以内的全部素数,求100~200之间的全部素数
  7. 关于DEV-c++ 运行窗口闪退的解决办法
  8. 不是人人都懂的学习要点
  9. 谷歌浏览器html插件字体大小,字体换加插件,自定义Chrome网页字体,更改字体样式,调整字体大小...
  10. python语言转换为go_从 Python 到 Golang-Go语言中文社区