0% found this document useful (0 votes)
4 views6 pages

Find

The 'find' command is used to search for files in a directory hierarchy based on various criteria such as name, size, type, and permissions. It allows users to execute actions on the found files, like deleting or modifying them. The command requires a specific location to search and has a variety of options to refine the search results.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Find

The 'find' command is used to search for files in a directory hierarchy based on various criteria such as name, size, type, and permissions. It allows users to execute actions on the found files, like deleting or modifying them. The command requires a specific location to search and has a variety of options to refine the search results.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

find utility

cmd: find
find command is use to search files with conditions in directory hierarchy. It is useful in finding
files with complex requirement. Such as filename, file size, file permission, file type, owner of
file uid, gid etc..
search files and executr command on this files such as chmod, grep, mv, cp, rm etc..
Find command requires a specific location, without location we cannot find file or directory.
syntax:
# find <source> <option> <expression> <action>
options:
-name  name of file/directory
-user  owner of file/dir
-perm  permission of file/dir
-uid  uid of file/dir
-gid  gid of file/dir
-iname  search files by name in case insensitive
-group  group owner of file/dir
-type  type of files
f  for normal file
d  directory
c character device file
p pipe file
l link file
s socket file
b block device file
-size  size of file
+100M more than 100M file
100M exact 100M file
-100M less than 100M file
-perm
/u=s suid applied files
/g=s sgid applied files
/o=t sticky bit applied files
-empty search empty files and directories
-delete  to delete searched file

amin  access minute ago


bmin birth minute ago
cmin chnage minute ago
mmin modify min ago

atime accessed time ago --> 1=1*24= 1day


btime birth time ago
ctime change time ago
mtime modify time ago

# options:

140 # -name --> search thr file by name

141 ls /

142 passwd

143 ls /etc/

144 ls /etc/ | grep passwd

145 find / -name passwd

146 ############################################

147 # -iname --> case insensitive

148 find / -iname passwd

149 #################################

150 # -type --> type of file

151 # f --> normal file

152 # d --> directory


153 # c --> character device file

154 # s --> socket file

155 # p --> pipe file

156 # l --> link file

157 # b --> block device file

158 find / -name "pass*"

159 find / -name "*wd"

160 find / -name pass??

161 find / -name ??ss??

162 ###############################################

163 find / -name passwd

164 find / -name passwd -type

165 find / -name passwd -type f

166 find / -name passwd -type d

167 ####################################

168 find / -type f

169 ls -l /proc/58/net/bnep

170 ~

171 ls -l /proc/58/net/bnep

172 ####################################

173 find / -type d

174 ls -ld /proc/495/fdinfo

175 ######################

176 find / -type b

177* ls -l /dev/sd

178 ###################################

179 find / -type c

180 ls -l /dev/tty0

181 ####################################

182 find / -type l

183
184 ls -l /lib64

185 ##########################################

186 # -user --> search file by user owner

187 find / -user akshay

188 ###############################

189 # -group --> search by group owner

190 find / -group testing

191 ################################

192 # -uid --> search by user owner id

193 id akshay

194 find / -uid 1014

195 ##################################

196 # gid --> search by goupr id

197 grep testing /etc/group

198 find / -gid 1028

199 ###################################

200 # -size --> size of file/dir

201 # -10M --> less than 10M file

202 # 10M --> exact 10M file

203 # +10M --> more than 10M

204 find / -size -10M

205 find / -size 10M

206 find / -size +10M

207 # ######################################

208 # -perm --> search file by permission

209 # /u=s --> suid applied files

210 # /g=s --> sgid applied files

211 # /o=t --> sticky bit files

212 find / -perm 775

213 find / -perm 775 -type d

214 find / -perm 775 -type f


215 ###########################

216 find / -perm 4775

217 find / -perm 4777

218 find / -perm 4555

219 find / -perm 4755

220 #################################

221 find / -perm /u=s

222 find / -perm /g=s

223 ls -ld /centos/

224 ls -ld /run/tpm2-tss/eventlog

225 ###########################

226 find / -perm /o=t

227 #######################################

228 ls /redhat/

229 ll /redhat/

230 find /redhat/ -perm /u=r

231 find /redhat/ -perm /g=w

232 find /redhat/ -perm /u=w

233 find /redhat/ -perm /o=x

234 find /redhat/ -perm /o=x -type f

235 find /redhat/ -perm /o=x -type d

236 ######################################

237 # -empty --> search empty file

238 find /redhat -empty

239 find /redhat -empty -type f

240 find /redhat -empty -type d

241 #########################################

242 # -delete --> delete searched file

243 find /redhat/ -name test

244 find /redhat/ -name test -delete

245 ls /redhat/
246 #####################################

247 # atime --> access time ago

248 # mtime --> modify time ago

249 # ctime --> change time ago

250 # btime --> birth time ago

251 # 1 =1* 24hrs --> 24hr 1 day

252 find / atime 1

253 find / ctime 2

254 find / mtime 4

255 find / btime 1

256 #################################

257 # amin --> access minute ago

258 # bmin --> birht minute ago

259 # cmin --> change minute ago

260 # mmin --> modify minute ago

261 find / amin 20

262 find / bmin 60

263 find / cmin 40

264 find / mmin 30

265 history

[root@server ~]#

[root@server ~]#

[root@server ~]#

[root@server ~]# #######################

[root@server ~]# # rm, chown , chgrp, mv, cp, chmod

[root@server ~]#

You might also like