Linux Find 命令详情解释

文件查找

  • 普通查询
  • find /etc -maxdepth 1 -type f -name "pa*"
  • 命令 目录... 查找深度 类型 文件名称包含
    • -type文件类型:f表示文件,不指定类型的话,文件和目录都会查找

    • -maxdepth查找深度:目录层级的意思,不指定的话,就按照最大深度来查找

    • "pa*": *表示匹配任意pa开头的内容,*号还可以写在开头


按照文件大小查找

  • 按照文件大小查找(单位kMG,k要小写,MG要大写,不带单位就按照B单位来查找)
    • 1.查找大于100M的文件
      • find / - type f -size +100M [root@localhost tmp]# find / -type f -size +100M
    • 2.查找小于2k的文件
      • find /root/nginx- 1.20.2 - type f -size -2k
    • 3.查找大于50M同时小于100M的文件
      • find / - type f -size +50M - and -size -100M

忽略大小写查询

  • find /etc -maxdepth 1 -iname "pa*"
    • # i是ignore的简写,忽略的意思

根据修改时间查找文件

  • [root@localhost ~]# stat 1.txt
  • 时间参数:atime mtime ctime amin mmin cmin #(time是按照天来查找,min是按分钟查找)
    • # 时间单位为天
    • find /opt -type f -mtime -1 #-1代表一天以内,+1一天以前
  • 时间单位为分钟

  • 查找1天之前,10天之内,修改过的文件

    • [root@localhost ~]# find /etc/ -type f -mtime +1 -and -mtime -10

取反 !

  • [root@localhost ~] # find /root -type f -name "*.txt" #
    • 找名称以.txt结尾的文件
    • /root/ 1. txt /root/学习前准备.txt
  • [root@localhost ~] # find /root -type f ! -name "*.txt"
    • # 找名称中不是.txt结尾的 文件 /root/.bash_logout

用户组查找

  • 根据用户来查找文件

    • [root@localhost ~] # useradd hao
    • [root@localhost ~] # find / -user hao
  • # 查找属于hao用户的所有目录和文件

  • 根据用户组来查

    • ​​​​​​​find / -group hao

​​​​​​​


相关推荐
知白守黑2672 小时前
docker资源限制
运维·docker·容器
霍格沃兹测试开发学社测试人社区2 小时前
新手指南:通过 Playwright MCP Server 为 AI Agent 实现浏览器自动化能力
运维·人工智能·自动化
ximy13353 小时前
AI服务器工作之服务器的种类分类
运维·服务器
恒创科技HK3 小时前
香港服务器CPU中E5和Gold的区别
运维·服务器
黄沐阳4 小时前
stp,rstp,mstp的区别
服务器·网络·php
一张假钞4 小时前
Ubuntu SSH 免密码登陆
linux·ubuntu·ssh
清静诗意4 小时前
在 Ubuntu 上安装 MinIO 并使用 Python 封装类操作对象存储
服务器·minio
Wang's Blog5 小时前
Linux小课堂: 文件操作警惕高危删除命令与深入文件链接机制
linux·运维·服务器
水月wwww6 小时前
操作系统——进程管理
linux·操作系统·vim·进程·进程调度
2501_915909067 小时前
iOS 混淆实战,多工具组合完成 IPA 混淆与加固(源码 + 成品 + 运维一体化方案)
android·运维·ios·小程序·uni-app·iphone·webview