Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Find Command

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Find commands

(find file from home -i for ignore cases latter filename)

#find /home -iname filename

( find the file in current directory -type d is for dir then directory name)
#find . -iname filename
#find . -type d -iname directoryname

( same as -type d but it use to find file )


#find . -type d -iname directoryname

( find all the .cfg extension file )


#find . -type -f -iname *.cfg
(it find those file which have mix word in filename it will show)
#find . -type f -iname "*mix*"
(find file from /etc/ -type f -iname which have conf in name in the middle )
#find /etc/ -type -f -iname "*conf*"

default linux directory permission is 755 and file have 644

(find those file whose have -perm 0777 permission and -print print all )
#find . -type f -perm 0777 -print
#find . -type f -perm 0644 -print

(find those file whose not have -perm 0777 permission and -print print all )
#find . -type f ! -perm 0777 -print

(find those file whose not have -perm 0644 permission and -print print all )
#find . -type f ! -perm 0644 -print

(find those file which have no permissions )


#find . -type f ! -perm 000 -print

sticky bit permissions those permission which change by only owner it use to save file
from hackers it denoted by 1 example 1551 .

(this command is useful for find sticky bit file permissions)


#find . -perm 1551
(find those file user have read only permission over the file)
#find . -perm /u=r

( g for group and o for others )


#find . -perm /g=r
#find . -perm /o=r

(find directory which have 777 permission and print -exec execute then command chmod
permission 775 put back commands in arry { } \; then execute)
#find . -type d -perm 777 -print -exec chmod 755 {} \;

( find file in current directory name is test and print and then rename file )
#find . -type d -iname test -print -exec cp {} text \; # { } source in this and destination

( find file in current directory name is start from mas print -exec execute and then remove
file )
#find . -type f -iname "mas*" -print -exec rm -rf { } \;

( mv all file which name is start from mas* to the /tmp/ location )
#mv mas* /tmp/

( find file from temp and type is file and -empty and print )
#find /temp/ -type f -empty -print

( find file which is empty and then print and execute command rm -rf and store source in
arry )
#find . -type f -empty -print -exec rm -rf {} \;

( this line is use to creat list of file from 2 to 4 and then end )
#for i in {2..5}; do touch "test$i"; done

( this file which belong to dev group it will be removed )


# find . -group dev -print -exec rm -rf {} \; # dev is group so creat it fisrt
#find . -group dev -print -exec chwon root:root {} \;

( find those file mttime modified time which is 50 days before )


#find / -mttime 50

( it use to find those file which is created before 2 days )


#find / -ctime 2
( it is similar like other but it find file on the basic of access time 2 days before )
#find / -atime 2

(find those file which is access from 2 to 6 days before )


#find / -atime 2 -attime -6

(find those file which is created before 10 min)


#find . -mmin 10

(find those file which is created past 60 min - is use to find past files)
#find . -mmin -60

You might also like