Linux Find Command 35 implementation examples

Source: Internet
Author: User

1. Use the-name option to find files in the current directory
# Find. -name Tecmint.txt./tecmint.txt
2. Find the file in the/home directory
# Find/home-name Tecmint.txt/home/tecmint.txt
3. Use name/ignoring to find files, ignoring case
# Find/home-iname Tecmint.txt./tecmint.txt./tecmint.txt
4. Use the [-name/-type] option to find the directory.
# Find/-type d-name Tecmint/tecmint
5. Use the-name option to find PHP files
# Find. -type F-name tecmint.php./tecmint.php
6. Find all the PHP files in a directory
# Find. -type f-name "*.php"./tecmint.php./login.php./index.php
7. Find all files with 777 permissions
# Find. -type F-perm 0777-print
8. Find all files with no 777 permissions
# Find/-type f! -perm 777
9. Find all 644 permissions for the Sgid file
# Find/-perm 2644
10. Find the sticky Bit file for 551 permissions
# Find/-perm 1551
Note: Sticky Bit--Directory restriction identifier.11. Find all Suid files
# Find/-perm/u=s
Note: suid--User ID12. Find all Sgid files
# Find/-perm/g=s
Note: sgid--group identification13. Find all read-only files
# Find/-perm/u=r
14. Find all execution files
# Find/-perm/a=x
15. Find all 777 permission files and modify them to 644 permissions
# Find/-type f-perm 0777-print-exec chmod 644 {} \;
16. Find all 777 permission directories and modify them to 755 permissions
# Find/-type d-perm 777-print-exec chmod 755 {} \;
17. Find a separate file and delete it
# Find. -type f-name "Tecmint.txt"-exec rm-f {} \;
18. Find multiple files and delete them
# Find. -type f-name "*.txt"-exec rm-f {} \;or# find. -type f-name "*.mp3"-exec rm-f {} \;
19. Find all empty files
# Find/tmp-type F-empty
20. Find All empty directories
# Find/tmp-type D-empty
21. Find all hidden files in the directory
# Find/tmp-type F-name ". *"
22. Locate the file in the user root directory
# Find/-user root-name tecmint.txt
23. Find all files belonging to user Tecmint in the/home directory
# Find/home-user Tecmint
24. Under the/home directory-belongs toDeveloper Group All Files
# Find/home-group Developer
25. Find all txt text files in the Tecrnint user-/home directory
# find/home-user Tecmint-iname "*.txt"
26. Find all files modified in the last 50 days
# Find/-mtime 50
27. Find all files accessed within 50 days
# Find/-atime 50
28. Find all files that have been modified within 50-100 days
# Find/-mtime +50–mtime-100
29. Find all files changed within 1 hours
# Find/-cmin-60
30. Find all files modified within 1 hours
# Find/-mmin-60
31. Find all the files accessed within 1 hours
# Find/-amin-60
32. Find all files of length 50MB
# Find/-size 50M
33. Find all files of length in 50MB-100MB
# Find/-size +50m-size-100m
34. Find and delete all files larger than 100MB
# Find/-size +100m-exec rm-rf {} \;
35. Find all files that are larger than 10MB and delete them mp3
# Find/-type f-name *.mp3-size +10m-exec rm {} \;



This article is from "Swiss departure-Next generation Enterprise Application" blog, declined reprint!

Linux Find Command 35 implementation examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.