File search command element

First, the search for executable files

1, which find the executable file and the path search command aliases

 是通过PATH环境变量到该路径内查找可执行文件,因此基本功能是寻找可执行的文件

Find the executable file:
Here Insert Picture Description

Find command path:
Here Insert Picture Description
Find command aliases:
Here Insert Picture Description

2, whereis search command can only be used where the search path name of the program and to help position the document resides

		-b:只查找二进制文件
		-m:只查找在说明文件manual路径下的文件

The following will passwd file to find out the relevant:
Here Insert Picture Description

3、locate

	locate:
		依赖于事先构建好的索引库,定时更新索引库  updatedb
		查找速度快,模糊查找 

		-b:只匹配路径中的基名
		-c:统计总共有多少符合条件个文件

4, find: search files

		find [options] [查找的起始路径] [查找条件] [处理动作]

		查找的起始路径:指定具体的搜索目录,默认为当前目录
		查找条件:指定查找的标准,大小,文件名,类型。默认是指定路径下的所有文件
		处理动作:符合查找条件的文件做出的操作,例如cp,rm,默认为输出到标准输出

Search Terms:

A: Expression:
				与 -a 
				或 -o
				非:-not  !
B: Find the file name:
			文件名查找:
				-name  "pattern"    --- 引号需要加
				支持通配符  * ? []  [^]
				-iname   "pattern"    不区分大小写
				基于正则表达式模式查找
				-regex  "pattern"    匹配整个路径  而不是文件名

				find /  -regex  /t.*/f.*
C: Find files based on affiliation
				-user   属主
				-group  属组
				-uid  GID  属主ID
				-gid  GID  属组ID

				-nouser  没有属主的文件
			-nogroup 没有属组的文件
D: Find file type
			-type  TYPE

			f:普通文件
			d:目录
			b:块设备文件
			l:链接文件
			c:字符设备文件
			p:管道文件
			s:socket套接字文件
E: -size [+|-] #UNIT
				#UNIT:(#-1,#]
				-#UNIT:[0,#-1)
				+#UNIT:(#,OO)

Find the / etc directory of greater than 1M for all types of files and regular files;
Here Insert Picture Description

F: Find based on timestamp
				以天为单位
				-atime   [+|-]# 文件最后访问时间
				-mtime	 [+|-]# 文件最后修改时间
				-ctime   [+|-]# 文件最后改变时间
					#:[#,#-1): 10   大于等于10天前,小于9天前
					-#:(#,0]    -10  最后的访问时间10天以内
					+#:(oo,#-1] +10  最后的访问时间在9天以前,包括9天

				查找最近10天访问的文件
G: in minutes
					-amin  [+|-]#
					-mmin  [+|-]#G
					-cmin  [+|-]#
H: According to locate the file permissions
				-perm  mode   777   rwx  421    
				权限对象:三类  属主 属组 其他
				权限位: 读  写 执行   r w x    4  2  1   
H:				mode 精确查找
				/mode:任何一个权限对象中满足其一即可
				-mode:所有都需要满足

					 421  精确,9位权限位所有的权限位保持一致
					/421 只要包含,且9位权限中每个权限中有一个满足即可     或
					-421 只要包含,且9位权限中每个权限均要满足             与

Find the / etc directory of all users do not have write access to the file
Here Insert Picture Description
Find / etc directory has at least file a class of user does not have permission to perform
Here Insert Picture Description

K: directory hierarchy
				-path 基于目录层级
		
				基于目录深度查找

				-maxdepth 最大深度
				-mindepth 最小深度

Find / etc directory Dir three files in the directory
Here Insert Picture Description

Processing operation

             -print: 默认动作,输出到标准输出作:
			-fls  /path/to/somefile:将查找到的文件的长格式信息写入到指定文件中
			-ok  commond  {} \;  对执行的每个文件做commond操作,每次的操作需要用户确认
			-exec commond {} \; 对执行的每个文件做commond操作
			-xargs -0 commond {} \;

ifconfig grep ip address:
Here Insert Picture Description

Published 10 original articles · won praise 1 · views 244

Guess you like

Origin blog.csdn.net/J19930611/article/details/104761287