Find Commands
1 . Find files using Name in current Directory
find . -name abc txt
2. Find xyz name files under abc directory
find /home/abc-name
xyz.txt
3. Find all .txt files in directories abc
find /home/abc -name".txt"
4. Find files using Name and
ignoring Case
find/home/abc/ -iname abc.txt
5. Find Directories
abc
find / type d -name abc
6. Find files Based on their permission
find -type f -perm
0777 -print
7. Find files without permissions
find . -type f ! -perm
0777 -print
8 .Find SDID Files with permission 755
find / -perm 2755
9 . Find all SDID set files
find / -perm /g+s
1 0. Find stick bit files with permission 755
find / -perm 1755
11. Find all SUID set
files
find / -perm
/u=s
12. Find all executable files
find / -perm /a=x
13. Fina all read only file
find / -perm /u=r
14. Find file with permission 777 and change the permission
to 755
find / -type -f -perm 077 -exec chmod
755 {} \;
find / -type -f -perm 0777 -pint0 | xargs - chmod 755
15. Find and remove single file
find / -type -f -name "acb.txt" -exec rm -f {}\;
find / -type -f -name "abc.txt" -pirnt0 | xargs -0
rm -f
16. Find all the files that were modified 10 days modified back
find / -mtime 10
17 . Find att the file that were accessed 10 days back
find -atime 10
18. Find all the files which are modified more than 10 days
back and less than 20 days
find / -mtime +10
-mtime -20
19. Find all the files modified in last 1 minute
find / -mmin -1
20. Find all the files changed in last 1 minutes
find / - type -f -cmin 1
21. Find a files based on user group
find / -user root -name abc.txt
22. Find all the files of a user
find / -user root
23. find a file based on group
find / -group developer -name syx.txt
24. Find all the files of group
find / -group developer
25. Find a 1o MB file
find -size 10M
26. Restricting find with search capability
find / maxdepth 3 -name ""log"
27. Find all files that dont match a filename pattern
find . -type f -not -name "*.html"
28. Redirecting erros to /dev.null
find -name "".txt" 2>>/dev/null
29 .Finding EARTH test in all the text files efficiently
find . -name "*.txt" -exce grep -i
"EARTH"{} \;
setuid or setgid
find / -perm /6000
setuid or setgid (POSIX):
find / -perm -4000 -o -perm -2000
No comments:
Post a Comment