Operations 7 min read

Mastering Linux find: 7 Powerful Ways to Locate and Manage Files

Learn how to harness the Linux find command with seven practical examples—including searching by name, type, timestamps, size, permissions, ownership, and executing actions—so you can efficiently locate and manage files, solve common interview questions, and automate system tasks.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Mastering Linux find: 7 Powerful Ways to Locate and Manage Files

Why the find command matters

The find utility is a fundamental tool for Linux system administrators and backend developers, enabling precise file discovery and batch operations directly from the command line.

Typical interview scenario

A common interview question asks how to delete log files in a logs directory that have not been accessed for over a year.

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

Basic syntax

Start in the target directory with cd, then use find followed by search criteria and optional actions.

Search by name or pattern

find . -name test.txt

To locate all PDF books:

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

Search by file type

Use -type to filter directories, symbolic links, etc.

find . -type d -name "yang*"
find . -type l -name "yang*"

Search by timestamps

atime : last access time.

mtime : last modification time.

ctime : last metadata change time.

Examples:

find . -type f -atime +365
find . -type f -mtime 5
find . -type f -ctime +5 -ctime -10

Search by size

Size units: b (512‑byte blocks, default), c (bytes), w (two‑byte words), k (KB), M (MB), G (GB). Use + for greater than and - for less than.

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

Search by permissions

find . -type f -perm 777

This finds files with read, write, and execute rights for owner, group, and others.

Search by ownership

find . -type f -user yang

Execute actions on found files

The -exec option runs a command on each matched file. The placeholder {} represents the current file, and the command must end with an escaped semicolon \;. find . -type f -atime +365 -exec rm -rf {} \; To list files older than five days without deleting them: find . -type f -atime +5 -exec ls {} \; Omitting the placeholder runs the command once, not per file.

Conclusion

By mastering these seven patterns—name, type, timestamps, size, permissions, ownership, and exec—you can solve the interview challenge and perform powerful file management tasks on any Linux system.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSysadminFile Searchfind command
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

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.