Mastering File Management in Linux: How to Find, Extract, and Copy Files Like a Pro

Vitalii Shloda
2 min readFeb 23, 2025

--

Managing files efficiently in Linux is a skill that every power user and system administrator should master. Whether you’re dealing with a messy directory structure or need to automate repetitive file tasks, the find command can be your best friend. In this guide, we'll walk you through how to locate, extract, and copy files from subdirectories effortlessly.

📌 Finding and Copying Image Files in Linux

Need to gather all your image files scattered across multiple directories? Use this simple command:

mkdir -p /path/to/destination && find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" -o -iname "*.bmp" -o -iname "*.tiff" \) -exec cp {} /path/to/destination \;

🔍 Breaking It Down:

  • mkdir -p /path/to/destination – Ensures the destination folder exists.
  • find . -type f – Searches for files in the current directory and all subdirectories.
  • -iname "*.jpg" -o -iname "*.png" – Filters only image files.
  • -exec cp {} /path/to/destination \; – Copies each found file to the target folder.

📝 Copying Documents in Linux

If you work with PDFs, Word documents, or text files, here’s how you can collect them into one place:

mkdir -p /path/to/documents && find . -type f \( -iname "*.pdf" -o -iname "*.docx" -o -iname "*.txt" \) -exec cp {} /path/to/documents \;

🎵 Organizing Audio Files

Want to declutter your music library? Use this command:

mkdir -p /path/to/audio && find . -type f \( -iname "*.mp3" -o -iname "*.wav" \) -exec cp {} /path/to/audio \;

🎬 Collecting Video Files

For handling large media collections, this command helps you consolidate your video files:

mkdir -p /path/to/videos && find . -type f \( -iname "*.mp4" -o -iname "*.avi" -o -iname "*.mkv" \) -exec cp {} /path/to/videos \;

🔄 Moving Files Instead of Copying

If you prefer to move files instead of copying them, just swap cp with mv:

mkdir -p /path/to/destination && find . -type f \( -iname "*.jpg" -o -iname "*.png" \) -exec mv {} /path/to/destination \;

🚀 Take Your File Management to the Next Level

Mastering the find command in Linux allows you to automate tedious file management tasks and improve your workflow. Whether you're organizing images, documents, or media files, these commands will help you work smarter.

For more Linux tips, automation guides, and system hacks, visit datahack.io.

💡 Save this guide and optimize your Linux workflow today!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Vitalii Shloda
Vitalii Shloda

Written by Vitalii Shloda

Software Engineer. I write about backend, data and other amazing stuff

No responses yet

Write a response