目录
一、根据文件名查找
查找 /tmp 目录下名字为 aming开头的所有文件。
[root@localhost ~]# find 路径 [选项] 搜索内容
选项:
-name: 按照文件名搜索
-iname: 按照文件名搜索,不区分文件名大小写
-inum: 按照 inode 号搜索
[root@192 tmp]# find /tmp -name "aming*"
搜索根目录下的 1.txt 2.txt 和 a 目录
[root@192 tmp]# find / -name 1.txt
[root@192 tmp]# find / -name 2.txt
[root@192 tmp]# find / -name a
搜索tmp目录下以 a 开头并且以 c 结尾的文件
[root@192 /]# find /tmp -name a*c
二、根据所有者和所属组进行搜索
2.搜索tmp目录下所属组group1,所属主user1的文件
[root@localhost ~]# find 搜索路径 [选项] 搜索内容
选项:
-uid 用户 ID: 按照用户 ID 查找所有者是指定 ID 的文件
-gid 组 ID: 按照用户组 ID 查找所属组是指定 ID 的文件
-user 用户名: 按照用户名查找所有者是指定用户的文件
-group 组名: 按照组名查找所属组是指定用户组的文件
-nouser: 查找没有所有者的文件
2.1根据所属主
[root@192 ~]# find /tmp -user zhaoliu
2.2更具所属组
[root@192 ~]# find /tmp -group zhaosi
三、按照文件大小搜索
搜索 tmp 目录下,不是以 a 开头,并且大小超过100M的文件
[root@192 /]# find /tmp -not -name a* -and -size +100M
没有不是以a开头且大于100m的文件