Linux find Command: 32 Examples, From Beginner to Pro Level

6/11/2025
Biisal
linuxfindcommand

176 views

Learn how to easily locate, filter, and manage files in Linux using the powerful find command. This beginner-friendly guide covers 32 practical examples with clear explanationsโ€”perfect for anyone new to the Linux terminal.

 Linux find Command: 32 Examples, From Beginner to Pro Level

๐Ÿ“ Master Linux find Command

The find command in Linux is used to search for files and directories based on different criteria such as name, size, permissions, modification time, and more. This guide explains 32 powerful find command examples that will make you pro in it.


1. ๐Ÿ” Find Files by Name

find /home/user/documents -name "example.txt"

This searches for a file named example.txt inside /home/user/documents.


2. ๐Ÿ” Find Files by Extension

find /var/log -name "*.log"

Finds all files ending with .log in /var/log directory.


3. ๐Ÿ•’ Find Files Modified in the Last 7 Days

find /etc -mtime -7

Lists files in /etc that were modified in the past 7 days.


4. ๐Ÿ•’ Find Files Modified More Than 30 Days Ago

find /usr/local -mtime +30

Searches for files not modified in the last 30 days.


5. ๐Ÿ—‘๏ธ Find and Delete Files

find /tmp -name "oldfile.txt" -delete

Deletes a file named oldfile.txt in /tmp.


6. ๐Ÿ“‚ Find Empty Files or Directories

find /var/www -empty

Shows all empty files and folders under /var/www.


7. ๐Ÿ“ฆ Find Files Larger Than 100MB

find /home/user/downloads -size +100M

Finds files bigger than 100MB in the downloads folder.


8. ๐Ÿ‘ค Find Files Owned by a Specific User

find /home -user username

Lists all files owned by the given username in /home.


9. ๐Ÿ” Find Files with 0644 Permissions

find /etc -perm 0644

Finds files with read/write permissions for the owner and read-only for others.


10. โš™๏ธ Find Files and Run a Command (Gzip Example)

find /var/log -name "*.log" -exec gzip {} \;

Compresses all .log files in /var/log using gzip.


11. ๐Ÿงน Delete Empty Files Using Command

find /home/user/documents -type f -empty -exec rm {} \;

Deletes all empty files in the documents folder.


12. ๐Ÿ“ƒ Find and Print File Details

find /home/user/documents -type f -exec ls -lh {} \;

Shows file sizes and details of all files in the folder.


13. ๐Ÿšซ Exclude a Specific Directory While Searching

find / -path "/proc" -prune -o -name "*.conf" -print

Searches for .conf files, but skips /proc directory.


14. ๐Ÿ• Find Files Modified in the Last Hour

find /var/www -mmin -60

Shows files modified in the last 60 minutes.


15. ๐Ÿ“ฆ Archive Files with a Specific Extension

find /home/user/pictures -name "*.jpg" | xargs tar -czvf archive.tar.gz

Archives all .jpg images in a tar.gz file.


16. ๐Ÿ”— Find Symbolic Links

find /usr/bin -type l

Shows all symbolic (soft) links in /usr/bin.


17. ๐Ÿ”ข Find Files by Inode Number

find / -inum 456332

Finds a file using its inode number (advanced).


18. ๐Ÿšซ Exclude a File Type

find /home/user -not -name "*.txt"

Finds all files except .txt files.


19. ๐Ÿ‘ฅ Find Files by Group Ownership

find /var/log -group syslog

Finds all files belonging to the syslog group.


20. ๐Ÿ“ Find Files Between 50MB and 100MB

find /home/user/downloads -size +50M -size -100M

Searches for files between 50MB and 100MB.


21. ๐Ÿ•“ Find and Sort by Modification Time

find /var/log -type f -exec ls -lt {} +

Shows files sorted by most recently modified.


22. ๐Ÿ• Find Files Modified in Last 2 Hours

find /var/log -mmin -120

Finds files updated in the last 2 hours.


23. ๐Ÿงโ€โ™‚๏ธ Find Files by User and Group

find /home -user username -group groupname

Finds files owned by a specific user and group.


24. ๐Ÿ” Find Files Only Readable by Owner

find /var/log -perm 600

Finds files with read/write access only for the owner.


25. ๐Ÿงน Delete Files Larger Than 1GB

find /var/log -size +1G -exec rm -f {} \;

Deletes files over 1GB in size.


26. ๐Ÿ” Limit Search Depth to 1 Level

find /home/user -maxdepth 1 -name "*.txt"

Searches for .txt files only in the top-level directory.


27. ๐Ÿ“… Find Files Accessed Over 90 Days Ago

find /var/log -atime +90

Lists files that havenโ€™t been accessed in 90+ days.


28. ๐Ÿ‘ป Find Hidden Files

find /home/user -name ".*"

Finds hidden files (those starting with a dot).


29. ๐Ÿ•’ Find Files Created More Than 1 Day Ago

find /home/user -ctime +1

Finds files created more than one day ago.


30. ๐Ÿ’พ Find Block Devices

find /dev -type b

Lists block devices (hard disks, USBs, etc).


31. ๐Ÿ” Exclude Files with Certain Permissions

find / -perm /a=w -not -perm /a=w

Finds files that do not have write permission for all.


32. ๐Ÿ” Find Files Containing a String in Their Name

find /home/user -name "*config*"

Searches for files with config in their name.


โœ… Thatโ€™s it

The find command is incredibly flexible and powerful. With it, you can locate, manage, and even delete files with precision. Play around with these commands in a test directory to get comfortable.Try here Blogrc Term or on your terminal.


Note: Always be cautious with delete operations (-delete, -exec rm)โ€”use them only when youโ€™re sure.

post not found
post not found
post not found
post not found