#man find
# find <path> <search Criteria> <action>
Examples of find command--
find
It will display the pathnames of all files in the current
directory and all subdirectories .
find.
find -print
find. -print
the below command will search abc file in the entire systemm
find /-name abc
Search in Current directory
find . -name abc.txt
to search a type as f , directory d
find . -type f -name abc.txt
find xyz files under abc directory
find/home/abc -name xyz.txt
find all .txt files in Directories abc
find /home/abc -name '*.txt'
find files using Name and ignoring Case
find /home/abc -iname abc.txt
find directories abc
find/ -type d -name abc
find files Based on their Permissions(permission 777)
find .-type f -perm 0777 -print
find files without permissions
find. -type f ! -perm 0777 -print
find SGID files with permission 755
find/ -perm 2755
find all SGID set files
find /-perm /g+s
find stick bit files with permission 755
find/ -perm 1755
Owner Group Others
7 7 7
r=4 w=2 x=1
ls -ltrh
find . -perm/o=t
owner only can delete this file no one can delete
find all SSUID set files
find . -perm/u=s
Find all executable files
find/ -perm /a=x
find all read only file
find /-perm /u=r
find file with permission 777 and change the permission to 755
find / -type -f -perm 0777 -exec chmod 755 {}\;
find / -type-f -perm 0777 -print0 | xargs -0 chmod 755
find and remove single file
find / -type -f -name "abc.txt" -exec rm-f {}\;
find /-type -f -name "abc.txt" -print0 |xargs -0 rm-f
find directories with 777 pemission and change permission 755
find /-type -d -perm 0777 -exec chmod 755 {}\;
find/ -type -d -perm 0777 -print0 |xargs -0 chmd 755
find all empty files and remove
find /-type f -empty -exec rm-f {}\;
find all hidden files
find /-type -f -name ".*"
find all thee files that were modified 10 days back
find / -mtime 10
find all the files that were accessed 10 days back
find /-atime 10
find all the files which are modified more than 10 days back
and less than 20 days
find / -mtime+10 -mtime -20
find all the files modified in last minute
find / -mmin 1
find all the files changed in last 1 minute
find / -type -f -cmin 1
find . -mmin 1
find .-mmin +1 -mmin -3
find a files based on user group
find / -user root -name abc.txt
find all the files of a user
find / -user root
find a file based on group
find / -group developer -name xyz.txt
find all the files of a group
find /-group developer
find a 10MB file
find /-size 10M
find . -size +1M -size -3M
find . -name '*.log'
restricting find with search capability
find / -maxdepth 3 -name "*log"
find all files that dont match a file name pattern
find. -type f -not -name "*.html"
redirecting errors to /dev/null
find -name "*.txt" 2>>/dev/null
finding EARTH text in all the text files
find . -name "*." -exec grep -i "EARTH"{}\;
finding EARTH text in all the text files efficiently
find . -name "*.txt" -exec grep-i "EARTH"{} \+
Clean out temporary files
find .\(-name a.out -o -name'*.o' -o -name 'core' \)exec rm {} \;
List zero length files
find . -empty -exec ls {} \;
find files which are more than 1 GB and nt accessed for the past
10 months
find / -size +1G -mtime +300
finding file dwnloaded today but misplaced
find ~ -type f -mtime 0 -iname '*.mp3'
identify files without a user or group
find / -nouser -o- nogroup
# find <path> <search Criteria> <action>
Examples of find command--
find
It will display the pathnames of all files in the current
directory and all subdirectories .
find.
find -print
find. -print
the below command will search abc file in the entire systemm
find /-name abc
Search in Current directory
find . -name abc.txt
to search a type as f , directory d
find . -type f -name abc.txt
find xyz files under abc directory
find/home/abc -name xyz.txt
find all .txt files in Directories abc
find /home/abc -name '*.txt'
find files using Name and ignoring Case
find /home/abc -iname abc.txt
find directories abc
find/ -type d -name abc
find files Based on their Permissions(permission 777)
find .-type f -perm 0777 -print
find files without permissions
find. -type f ! -perm 0777 -print
find SGID files with permission 755
find/ -perm 2755
find all SGID set files
find /-perm /g+s
find stick bit files with permission 755
find/ -perm 1755
Owner Group Others
7 7 7
r=4 w=2 x=1
ls -ltrh
find . -perm/o=t
owner only can delete this file no one can delete
find all SSUID set files
find . -perm/u=s
Find all executable files
find/ -perm /a=x
find all read only file
find /-perm /u=r
find file with permission 777 and change the permission to 755
find / -type -f -perm 0777 -exec chmod 755 {}\;
find / -type-f -perm 0777 -print0 | xargs -0 chmod 755
find and remove single file
find / -type -f -name "abc.txt" -exec rm-f {}\;
find /-type -f -name "abc.txt" -print0 |xargs -0 rm-f
find directories with 777 pemission and change permission 755
find /-type -d -perm 0777 -exec chmod 755 {}\;
find/ -type -d -perm 0777 -print0 |xargs -0 chmd 755
find all empty files and remove
find /-type f -empty -exec rm-f {}\;
find all hidden files
find /-type -f -name ".*"
find all thee files that were modified 10 days back
find / -mtime 10
find all the files that were accessed 10 days back
find /-atime 10
find all the files which are modified more than 10 days back
and less than 20 days
find / -mtime+10 -mtime -20
find all the files modified in last minute
find / -mmin 1
find all the files changed in last 1 minute
find / -type -f -cmin 1
find . -mmin 1
find .-mmin +1 -mmin -3
find a files based on user group
find / -user root -name abc.txt
find all the files of a user
find / -user root
find a file based on group
find / -group developer -name xyz.txt
find all the files of a group
find /-group developer
find a 10MB file
find /-size 10M
find . -size +1M -size -3M
find . -name '*.log'
restricting find with search capability
find / -maxdepth 3 -name "*log"
find all files that dont match a file name pattern
find. -type f -not -name "*.html"
redirecting errors to /dev/null
find -name "*.txt" 2>>/dev/null
finding EARTH text in all the text files
find . -name "*." -exec grep -i "EARTH"{}\;
finding EARTH text in all the text files efficiently
find . -name "*.txt" -exec grep-i "EARTH"{} \+
Clean out temporary files
find .\(-name a.out -o -name'*.o' -o -name 'core' \)exec rm {} \;
List zero length files
find . -empty -exec ls {} \;
find files which are more than 1 GB and nt accessed for the past
10 months
find / -size +1G -mtime +300
finding file dwnloaded today but misplaced
find ~ -type f -mtime 0 -iname '*.mp3'
identify files without a user or group
find / -nouser -o- nogroup
No comments:
Post a Comment