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. 02Django入门仪式之Hello World
  2. 5下载的demo在哪_归类专业能力水平评价练习盘!快来下载呀
  3. 2017广西邀请赛重现赛
  4. Java 多文件上传
  5. 让MessageBox在最前面弹出来的信息在
  6. 在Ubuntu下运行 apt-get update命令后出现错误:
  7. 矩形覆盖-----批了外皮的亲蛙跳
  8. OwinStartupAttribute
  9. java案例代码2-素数判断测试
  10. C++中带默认参数的函数定义及使用总结
  11. xshell以及xftp免费版
  12. Linux下ALSA驱动分析
  13. AI之DS:人工智能领域之数据科学领域六大实践场景(金融信用违约、反欺诈模型、客户偏好洞察、智能推荐、精准营销、客户流失管理)所对应的机器学习算法总结(持续更新)
  14. NISP和CISP考试通过率怎样?
  15. 巴斯勒相机的ip掩码_basler调相机规范步骤
  16. 高频消息中间件面试题解析
  17. 20210729 线性增长条件和全局Lipschitz条件的关系
  18. redis desktop manager安装以及使用教程
  19. 这个英文语法校正插件很赞!可以校正邮件,也可以校正论文
  20. NodeJS之搭建Web服务器

热门文章

  1. Python之quote() unquote()使用
  2. 思科无线服务器,Cisco统一无线网络TACACS+配置
  3. qpython 3h下载_QPython 3Hv3.0.0 Android
  4. 面包板电源线怎么接_面包板的结构和使用方法详细介绍
  5. Redis基础--Redis 4.0 常用配置
  6. IBM Websphere CEI Configuration
  7. 用js企业微信推送通知
  8. php 七牛云 视频加水印
  9. celery异步发送邮箱
  10. 2022-Java学习路线梳理