Embarking on a journey into the world of Linux, let's shine a light on a handy tool called 'Find.' In the vast land of managing and finding files, the 'Find' command is like a trusty guide, helping you locate and organize files precisely. This blog will break down the 'Find' command, giving you the lowdown on how to use it, practical ways to apply it, and some tips for efficient file searches. Whether you're a curious Linux learner or someone wanting to boost their skills, come along as we explore the heart of the 'Find' command, making Linux easier and more organized for you
Find Command Syntax
find [option] [path] [expression]
Multiple Use Case Of Find Command
Case 1: How To Search A File On Their Size
find /path/ -size 25M
M for MB, K for KB, G for GB, C for bytes
Case 2: How To Find Only File Or Only Directory In A Given File Path
find /path/ -type f
f for file, d for directory, I for symbolic link, b for block device, s for socket
Case 3: How To Search File By It's Name
find /path/ -name <file name>
Case 4: How To Ignore Upper & Lower Case In File Name While Searching Files
find /path/ -iname <file_name>
Case 5: How To Search File For A Given User Only
find /path/ -user root
Case 6: How To Search File Based On inode No.
find /path/ -inum <inode no. of file>
Case 7: How To Search File Based On OF Links
find /path/ -links <no. of links>
Case 8: How To Search Based On Their Permissions
find /path/ -perm /u=x
find /path/ -perm 755
Case 9:How To Search All Files Which Starts With Letter d
find /path/ -iname d*
Case 10: How to Search Files Which Are Modified / Created After last.txt File
find /path/ -newer last.txt
Case 11: How To Search Empty Files In The Given Directory
find /path/ -empty
Case 12: How To Search Empty Files IN The Given Directory And Same Time Delete Them
find /path/ - empty -exec rm {} /;
Case 13: How To Search File Whose Size Lies Between 1-100MB
find /path/ -size +1M -size -100M
Case 14: How To Search 10 Days Old Files
find /path/ -mtime 10