How to find files In Linux

Spread the love

In this article i will explain you to how to find files in Linux.

Find at current location
# find  . -name abc.txt   

Find file name case insensitively
# find / -iname abc.txt   

Find the file in / .
# find / -name *.txt       

Find the file where ‘pass’ in /etc
# find /etc -name *pass*   

Find the file in /data created by macho
# find / -user macho       

Find the file in /data which is not created by macho
# find / -not -user macho   

Find the file with uid of 500
# find / -user macho -uid 500   

Matches if mode is exactly 755
# find / -perm 755       

Matches if anyone can write
# find / -perm +222       

Matches if everyone can write
# find / -perm -222       

Matches if other can write
# find / -perm -002          

Files with a size of exactly 10M
# find / -size 10M       

Files with a size of above 10M
# find / -size +10M       

Files with a size of less than 10M
# find / -size -10M       

When file was last read (min)
# find / -amin 10       

When file data last changed
# find / -mmin -10       

When file data or metadata last changed
# find / -cmin 10       

By this commnad linux find only file with exetantion .txt and
copy again with .doc ( -exec not ask to do )
# find / -name “*.txt” -exec cp {} {}.doc ;
   
Linux find only those file with permisssion 002 and execute
it again 777 ( or full permission )
# find / -perm -002 -exec chmod 777 {} ;
   
    -exec     execute directly
    -ok    asking to do

See also  How to enable directory listing in Nginx

# find / -name “*.doc” -ok rm {} ;

Incase you want to check all the foders site in directory
# du -h –max-depth=1 /home | sort -h

Thanks,
Vishal Vyas

Linuxguru

1 thought on “How to find files In Linux”

Leave a Comment