Saturday 4 January 2014

Find Command in Linux with Examples

FIND:- Find  - searches for files in a directory hierarchy

FIND command  uses and example

(1) Find all files whose name is abc in pwd (Present Working Directory)
[root@CLIENT ~ ] #  find . -name abc
./abc

(2) Find all file in /home directory  whose name is abc
[root@CLIENT ~ ] # find  /home  -name  abc

(3) Find all file whose name is abc ignoring case senstivity
[root@CLIENT ~ ] # find /home  -iname abc

(4) Find a directory in  /home directory  whose name is arun
[root@CLIENT ~ ] # find /home -type d -name arun
/home/arun

(5) Find all html files in Linux file system
[root@CLIENT ~ ] # find  / -type f -name "*.html"

(6) Find files base on their permissions
[root@CLIENT ~ ] # find  / -type f   -perm 700

(7) Find all files with their permission 700 and change permission with  600
[root@CLIENT ~ ] # find  / -type  f  -perm 700 -exec chmod 600 {} \;

(8) Find all files  base on user arun
[root@CLIENT ~ ] # find  /  -user arun

(9) Find all files  base on group Linux
[root@CLIENT ~ ] # find  /  -group Linux

(10) Find a particular file named abc.txt of user arun
[root@CLIENT ~ ] # find  /  -type f -user arun -name abc.txt

(11) Find files and directory on base of date and time

-atime    access time              |          +90          more than 90 days back
-mtime   modified time           |           90           exact 90 days back
-ctime    change time             |           -90          less than 90 days back

[root@CLIENT ~ ] #  find  / -ctime +90

(12) Find  files whose size is less than 10 MB
[root@CLIENT ~ ] #  find  /  -size  -10M

(13) Find  files whose size is less than 100 MB and more than 50 MB
[root@CLIENT ~ ] #  find  /  -size  -100M  -size  +50M











3 comments: