find Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

The find command in Linux is a powerful tool that assists users in locating files or directories on their system. It allows for a wide range of search criteria and can be used in scripts for complex file management tasks. With the find command in Linux, you can search by name, type, size, and even by the time files were last accessed, modified, or changed.

Syntax of find Command in Linux

The basic syntax of the find command in Linux is as follows:

Where:

  • where: This is the location where the find command starts its search. It could be a directory, such as /home/username/, or it could be '.', which represents the current directory.
  • what: These are the search criteria. It can be the name, type, size, or time of the file or directory.
Sharpen Your Fundamentals with Free Learning

Options in find Command in Linux

  1. -name: Search for a file by its name.

    For example -

    Output:

    This command searches for a file named 'example.txt' in the current directory and its subdirectories.

  2. -type: Search for a file by its type.

    For example -

    Output:

    This command lists all directories in the current directory and its subdirectories.

  3. -size: Search for a file by its size.

    For example -

    Output:

    This command searches for files larger than 1 Megabyte in the current directory and its subdirectories.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Find files modified in the last day:

    Output:

    Explanation: This command lists all files that were modified within the last day in the current directory and its subdirectories.

  • Find and delete files with a specific extension:

    Explanation: This command deletes all files with the .tmp extension in the current directory and its subdirectories.

Tips

  • Always be careful when using the -delete option, as it does not ask for confirmation before deleting files.

  • Using -iname instead of -name makes the search case insensitive.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of find Command in Linux

  • Find and compress all .jpg files:

    Explanation: This command finds all .jpg files in the current directory and its subdirectories and adds them to a tar archive named images.tar.

  • Find files not accessed in the last 10 days:

    Output:

    Explanation: This command lists all files that have not been accessed in the last 10 days in the current directory and its subdirectories.

  • Find and change file permissions:

    Explanation: This command finds all files in the current directory and its subdirectories and changes their permissions to 644 (read and write for the owner, and read for the group and others).

Conclusion

  • The find command in Linux is a versatile and powerful tool for locating files and directories based on various criteria.

  • Be careful when using options that can modify or delete files, such as -delete or -exec.

  • The find command in Linux can be combined with other commands using the -exec option for more complex file management tasks.