Operations 7 min read

7 Practical Uses of the Linux find Command

This article explains seven real‑world applications of the Linux find command, covering file name patterns, type filtering, timestamps, size, permissions, ownership, and executing actions on matched files, with clear examples for system administrators and developers.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
7 Practical Uses of the Linux find Command

It is essential for backend developers and system administrators to master the Linux find command, especially for interview questions such as deleting log files older than one year in a logs directory.

The solution is to change to the target directory and run:

find . -type f -atime +365 -exec rm -rf {} \;

The article then presents seven practical uses of find :

1. Find files by name or regular expression

Search by exact name:

find . -name test.txt

Search in another path:

find ./yang/books -name test.pdf

Search by pattern (e.g., all PDFs):

find ./yang/books -name "*.pdf"

Specify file type for clarity:

find ./yang/books -type f -name "*.pdf"

2. Find different types of files

Search directories:

find . -type d -name "yang*"

Search symbolic links:

find . -type l -name "yang*"

3. Find files by timestamps

Linux tracks three timestamps: atime (last access), mtime (last modification), and ctime (last metadata change). To find files accessed over a year ago:

find . -type f -atime +365

Find files modified exactly 5 days ago (no + sign):

find . -type f -mtime 5

Find files whose ctime is between 5 and 10 days ago:

find . -type f -ctime +5 -ctime -10

4. Find files by size

Size units: b (512 bytes), c (bytes), w (2‑byte words), k (KB), M (MB), G (GB). Example to find files between 10 MB and 1 GB:

find . -type f -size +10M -size -1G

5. Find files by permissions

Search files with permission 777:

find . -type f -perm 777

6. Find files by ownership

Search files owned by user yang :

find -type f -user yang

7. Execute a command on found files

Use -exec to run a command for each matched file, e.g., delete files older than a year:

find . -type f -atime +365 -exec rm -rf {} \;

The placeholder {} represents each found file; the command must end with an escaped semicolon \; . The article also shows the difference when the placeholder is omitted.

Conclusion

After reviewing the seven uses of find , the initial interview question becomes straightforward, and readers can confidently write and explain the command.

operationslinuxCommand-lineSysadminfile-searchfind command
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.