Operations 8 min read

Mastering Linux Find: 8 Powerful Use Cases for System Operations

This article explains why the Linux find command is essential for administrators, walks through a common interview question about deleting year‑old log files, and then presents eight practical find usages—including name patterns, file types, timestamps, size, permissions, ownership, execution actions, and directory searches—complete with ready‑to‑run code examples.

Efficient Ops
Efficient Ops
Efficient Ops
Mastering Linux Find: 8 Powerful Use Cases for System Operations

The find command is a must‑know tool for Linux operations and system administration.

Interview question: How to delete log files in a .logs directory that haven’t been accessed for over a year?

<code>find . -type f -atime +365 -exec rm -rf {} \;</code>

If you’re not comfortable with the command above, this article introduces eight practical

find

use cases that will help you master it.

1. Find files by name or regular expression

Search for a specific file name:

<code>find . -name test.txt</code>

Search for all PDF books using a pattern:

<code>find ./yang/books -name "*.pdf"</code>

Specify the file type for clarity:

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

2. Find files of different types

Search for directories:

<code>find . -type d -name "yang*"</code>

Search for symbolic links:

<code>find . -type l -name "yang*"</code>

3. Find files by timestamp

Linux tracks three timestamps:

atime : last access time.

mtime : last modification time.

ctime : last status change time (ownership, permissions, etc.).

Find files with access time older than one year:

<code>find . -type f -atime +365</code>

Find files with modification time exactly five days ago (no

+

sign):

<code>find . -type f -mtime 5</code>

Find files with change time between five and ten days ago:

<code>find . -type f -ctime +5 -ctime -10</code>

4. Find files by size

Use

-size

with units (b, c, w, k, M, G):

<code>find . -type f -size +10M -size -1G</code>

5. Find files by permissions

Search for files with specific permission bits (e.g., 777):

<code>find . -type f -perm 777</code>

6. Find files by ownership

Search for files owned by a specific user:

<code>find -type f -user yang</code>

7. Execute a command on found files

After locating files, you can run actions such as delete or list them using

-exec

:

<code>find . -type f -atime +5 -exec ls {} \;</code>

Note: the command after

-exec

must end with an escaped semicolon (

\;

).

8. Search by directory name

Find directories by name (case‑sensitive):

<code>find /path/to/search -type d -name "directory_name"</code>

Case‑insensitive search:

<code>find /path/to/search -type d -iname "directory_name"</code>

Find the most recently modified directory:

<code>find /path/to/search -type d -printf '%T+ %p\n' | sort -n | tail -1</code>

After reviewing these eight techniques, the original interview question becomes straightforward; you can now provide the exact command and explain each part.

LinuxshellSystem Administrationfile-searchfind command
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

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.