Part I - Basic Find Commands for Finding FiIes with Names
1. Find FiIes Using Name in Current Directory
Find all the fles whose name is tecmint.txt in a current working directory. # i1nd . -name lecm1nl.lxl .1lecm1nl.lxl 2. Find FiIes Under Home Directory Find all the fles under /home directory with name tecmint.txt. # i1nd 1home -name lecm1nl.lxl 1home1lecm1nl.lxl 3. Find FiIes Using Name and Ignoring Case Find all the fles whose name is tecmint.txt and contains both capital and small letters in /home directory. # i1nd 1home -1name lecm1nl.lxl .1lecm1nl.lxl .1Tecm1nl.lxl 4. Find Directories Using Name Find all directories whose name is Tecmint in / directory. # i1nd 1 -lype d -name Tecm1nl 1Tecm1nl 5. Find PHP FiIes Using Name Find all php fles whose name is tecmint.php in a current working directory. # i1nd . -lype i -name lecm1nl.php .1lecm1nl.php 6. Find aII PHP FiIes in Directory Find all php fles in a directory. # i1nd . -lype i -name "*.php" .1lecm1nl.php .1lo1n.php .11ndex.php Part II - Find FiIes Based on their Permissions 7. Find FiIes With 777 Permissions Find all the fles whose permissions are 777. # i1nd . -lype i -perm 0777 -pr1nl 8. Find FiIes Without 777 Permissions Find all the fles without permission 777. 35 Practical Examples of Linux Find Command http://www.tecmint.com/35-practical-examples-of-linux-fn... 2 of 10 11/12/2013 12:19 PM # i1nd 1 -lype i ! -perm 777 9. Find SGID FiIes with 644 Permissions Find all the SGID bit fles whose permissions set to 644. # i1nd 1 -perm 2644 10. Find Sticky Bit FiIes with 551 Permissions Find all the Sticky Bit set fles whose permission are 551. # i1nd 1 -perm 1551 11. Find SUID FiIes Find all SUID set fles. # i1nd 1 -perm 1u=s 12. Find SGID FiIes Find all SGID set fles. # i1nd 1 -perm 1+s 13. Find Read OnIy FiIes Find all Read OnIy fles. # i1nd 1 -perm 1u=r 14. Find ExecutabIe FiIes Find all ExecutabIe fles. # i1nd 1 -perm 1a=x 15. Find FiIes with 777 Permissions and Chmod to 644 Find all 777 permission fles and use chmod command to set permissions to 644. # i1nd 1 -lype i -perm 0777 -pr1nl -exec chmod 644 {) \, 16. Find Directories with 777 Permissions and Chmod to 755 Find all 777 permission directories and use chmod command to set permissions to 755. # i1nd 1 -lype d -perm 777 -pr1nl -exec chmod 755 {) \, 17. Find and remove singIe FiIe To fnd a single fle called tecmint.txt and remove it. # i1nd . -lype i -name "lecm1nl.lxl" -exec rm -i {) \, 18. Find and remove MuItipIe FiIe To fnd and remove multiple fles such as .mp3 or .txt, then use. # i1nd . -lype i -name "*.lxl" -exec rm -i {) \, 0R # i1nd . -lype i -name "*.mp3" -exec rm -i {) \, 19. Find aII Empty FiIes To fle all empty fles under certain path. 35 Practical Examples of Linux Find Command http://www.tecmint.com/35-practical-examples-of-linux-fn... 3 of 10 11/12/2013 12:19 PM # i1nd 1lmp -lype i -emply 20. Find aII Empty Directories To fle all empty directories under certain path. # i1nd 1lmp -lype d -emply 21. FiIe aII Hidden FiIes To fnd all hidden fles, use below command. # i1nd 1lmp -lype i -name ".*" Part III - Search FiIes Based On Owners and Groups 22. Find SingIe FiIe Based on User To fnd all or single fle called tecmint.txt under / root directory of owner root. # i1nd 1 -user rool -name lecm1nl.lxl 23. Find aII FiIes Based on User To fnd all fles that belongs to user Tecmint under /home directory. # i1nd 1home -user lecm1nl 24. Find aII FiIes Based on Group To fnd all fles that belongs to group DeveIoper under /home directory. # i1nd 1home -roup developer 25. Find ParticuIar FiIes of User To fnd all .txt fles of user Tecmint under /home directory. # i1nd 1home -user lecm1nl -1name "*.lxl" Part IV - Find FiIes and Directories Based on Date and Time 26. Find Last 50 Days Modied FiIes To fnd all the fles which are modifed 50 days back. # i1nd 1 -ml1me 50 27. Find Last 50 Days Accessed FiIes To fnd all the fles which are accessed 50 days back. # i1nd 1 -al1me 50 28. Find Last 50-100 Days Modied FiIes To fnd all the fles which are modifed more than 50 days back and less than 100 days. # i1nd 1 -ml1me +50 -ml1me -100 29. Find Changed FiIes in Last 1 Hour To fnd all the fles which are changed in last 1 hour. 35 Practical Examples of Linux Find Command http://www.tecmint.com/35-practical-examples-of-linux-fn... 4 of 10 11/12/2013 12:19 PM December 24, 2012 at 11:41 am hi! glad i found your site and the informative articles. question re: "35 Practical Examples of Linux Find Command": in # 3. ' fnd /home -iname tecmint.txt`, what is proper way to flter results of this command such that the Uppercase results are sorted from the lowercase results? ex.: ... Techmint.com Techmint.com1 Techmint.com2 ... techmint.com techmint.com1 techmint.com2, etc., etc., etc. Thanks again for all the good info. Have A Healthy, Prosperous Day! -rob Reply Mac says: January 29, 2013 at 9:27 pm Can you explain this option to me, I am new to the command line - still learning. #15 # fnd / -type f -perm 0777 -print -exec chmod 644 {} \; the symbols {} and the \ I am a bit confused, any help/advice would be great. Reply Ravi Saive says: January 30, 2013 at 10:56 am @Mac, Please join us on Facebook at Linux Inside, you will get the answer for this. Reply Melvin says: March 23, 2013 at 8:13 pm The brackets are placeholders for the fle that fnd, fnds and the \ is so that the shell does not interpret the semicolon (;), which would normally end the command. Reply 3. vijaya says: July 2, 2013 at 1:50 pm It is really helpful for beginners thanks. Reply 4. Luis says: July 14, 2013 at 12:03 am como recuperar los archivos eliminados con el comando # fnd / -type f -name *.mp3 -size +10M -exec ls -l {} \; Reply 5. Joe says: September 16, 2013 at 8:10 pm 6. 35 Practical Examples of Linux Find Command http://www.tecmint.com/35-practical-examples-of-linux-fn... 7 of 10 11/12/2013 12:19 PM Know More Submit Order Advertise Now :: About :: TecMint.com is a website that publishes practical and useful out-of-the-box articles for aspirant like you and me. We seek to present exceptional, remarkable tips, tutorials, and resources that the modern web professional will appreciate. :: Our Services :: We offer wide range of Linux Web Hosting and Management Services includes Linux hosting, WordPress hosting, Joomla Hosting, CMS hosting, Website migration and Custom solutions, making us a one-stop destination for all your possible hosting needs at fair minimum rates. :: Advertise :: TecMint.com is visited by tens of thousands of Linux users and has a excellent reputation in the search engine ranking. Most of the traffc comes from Google organic search (80%). Spread your messages or products to an engaged readers by advertising with us. Home l Privacy Policy l Copyright Policy 2012-2013 All Rights Reserved. 25 Hardening Security Tips for Linux Servers 60 Commands of Linux : A Guide from Newbies to System Administrator 15 Command Line Tools to Monitor Linux Performance 5 Best Practices to Secure and Protect SSH Server 18 Tar Command Examples in Linux 20 Linux YUM (Yellowdog Updater, Modifed) Commands 25 Useful Basic Commands of APT-GET and APT-CACHE 20 Funny Commands of Linux or Linux is Fun in Terminal 35 Practical Examples of Linux Find Command 10 Linux Distributions and Their Targeted Users 35 Practical Examples of Linux Find Command http://www.tecmint.com/35-practical-examples-of-linux-fn... 10 of 10 11/12/2013 12:19 PM