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

​​​​​​​


相关推荐
小成202303202652 小时前
Linux高级02
linux·开发语言
mounter6252 小时前
【硬核前沿】CXL 深度解析:重塑数据中心架构的“高速公路”,Linux 内核如何应对挑战?-- CXL 协议详解与 LSF/MM 最新动态
linux·服务器·网络·架构·kernel
++==2 小时前
Linux 进程间通信与线程同步技术详解:IPC 机制、线程 API、同步工具与经典同步问题
linux
特长腿特长3 小时前
centos、ubantu系列机的用户和用户组的结构是什么?具体怎么配置?用户组权限怎么使用?这篇文章持续更新,帮助你复习linux的基础知识
linux·运维·centos
zzzyyy5383 小时前
Linux环境变量
linux·运维·服务器
pluvium273 小时前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
无级程序员3 小时前
centos7 安装 llvm-toolset-7-clang出错的问题解决
linux·centos
kebeiovo3 小时前
atomic原子操作实现无锁队列
服务器·c++
赛博云推-Twitter热门霸屏工具4 小时前
Twitter运营完整流程:从0到引流获客全流程拆解(2026)
运维·安全·自动化·媒体·twitter
CHHC18804 小时前
NetCore树莓派桌面应用程序
linux·运维·服务器