SlideShare a Scribd company logo
1 of 5
Download to read offline
thegeekscope.com                        http://w w w .thegeekscope.com/find-files-in-linux-using-find-
                                           command/



Find Files in Linux using Find Command
In Linux, find Command is used to search for specific files and folders. The beauty of the linux find
command lies in its ability to perform complex searches. Find command provides plenty of options to
specify size, modification date, type, owner, permission while performing a search operation.

This article describes some of the most useful options availble with the linux find command with the
help of examples.


Find Files Based on Filename Pattern
Syntax:


 find <SEARCH_PATH> -type [f|d] -name "<PATTERN>"


type ‘f’ indicates that search for files
type ‘d’ indicates that search for directories
                                    The Geek Scope
Example: Search for files in the /root folder which contains the string “monitor” in the filename


 # find /root -type f -name "*monitor*"
 /root/monitor_script.sh
 /root/monitor_script.sh.v2
 /root/monitor_script.sh.v1


Example: Search for folders in the /root folder which contains the string “monitor” in the foldername


 # find /root -type d -name "*monitor*"
 /root/test/test_monitor123


Example: Search for files/folders in the /root folder which contains the string “monitor” in the name


 # find /root -name "*monitor*"
 /root/test/test_monitor123
 /root/monitor_script.sh
 /root/monitor_script.sh.v2
 /root/monitor_script.sh.v1


                                                                          www.thegeekscope.com
Find Files Based on Modification Time in Days
Syntax:


 find <SEARCH_PATH> -mtime <x>


          Integer <x> indicates days

          <x> along with ‘+’ sign indicates, modified before x days

          <x> along with ‘-’ sign indicates, modified within last x days

          <x> with no sign indicates, modified exactly x days ago

Example: Search /etc folder for files/folders modified exactly 7 days ago


 # find /etc -mtime 7


Example: Search /etc folder for files/folders modified before 7 days


 # find /etc -mtime +7
                                       The Geek Scope
Example: Search /etc folder for files/folders modified in last 7 days


 # find /etc -mtime -7


You can use ‘atime‘ in place of ‘mtime’ to find files and folders based on last access time in days.

Example: Search /etc folder for files/folders accessed in last 7 days


 # find /etc -atime -7


Find Files Based on Modification Time in Mins
Syntax:


 find <SEARCH_PATH> -mmin <x>


          Integer <x> indicates minutes

                                                                           www.thegeekscope.com
<x> along with ‘+’ sign indicates, modified before x mins

          <x> along with ‘-’ sign indicates, modified within last x mins

          <x> with no sign indicates, modified exactly x mins ago

Example: Search /home folder for files/folders modified exactly 60 minutes ago


 # find /home -mmin 60


Example: Search /home folder for files/folders modified before 60 minutes


 # find /home -mmin +60


Example: Search /home folder for files/folders modified in last 60 minutes


 # find /home -mmin -60


You can use ‘amin‘ in place of ‘mmin’ to find files and folders based on last access time in mins.

                                     The Geek Scope
Example: Search /etc folder for files/folders accessed in last 60 mins


 # find /etc -amin -60


Find Files Based on Size
Syntax:


 find <SEARCH_PATH> -size <x>


Integer <x> indicates size in bytes/kilobytes/megabytes/gigabytes

          <x> along with ‘+’ sign indicates size larger than x

          <x> along with ‘-’ sign indicates size smaller than x

          <x> with no sign indicates, size exactly equal to x

Example: Search /etc folder for files/folders having size exactly equal to 20015 bytes



                                                                           www.thegeekscope.com
# find /etc -size 20015c


Example: Search /root folder for files/folders having size greater than 2 megabytes


 # find /etc -size +2M


Example: Search /home folder for files/folders having size less than 1 kilobytes


 # find /etc -size -1k


Find Files Based on Permissions
Syntax:


 find <SEARCH_PATH> -perm <permission>


Example: Search /etc folder for files/folders with permission 755 (read,write,execute for owner and
read,execute for group owner and others)
                                   The Geek Scope
 # find /etc -type f -perm 664



Find Empty files and Folders
Syntax:


 find -empty


Example: Find all empty files/folders available in a system


 # find / -empty



Find Files Owned by a Specific User
Syntax:


 find <SEARCH_PATH> -user <username>
                                                                      www.thegeekscope.com
Example: Find all files/folders owned by user ‘kam’


 # find / -user kam



Find Files Owned by a Specific Group
Syntax:


 find <SEARCH_PATH> -group <groupname>


Example: Find all files/folders owned by group account ‘projectx’


 # find / -group projectx


Use ‘-and’ and ‘-or’ qualifier to join search patterns
Example: Search /root folder for files/folders modified in last 7 days and having size less than 200kB

                                   The Geek Scope
 # find /etc -mtime -7 -and -size -200k


Example: Search /home folder for files/folders accessed in last 2 hours or having size greater than
10MB


 # find /etc -amin -120 -or -size +10M


Tagged as: Find Command, Find Files, Find files in LInux, Find files in Unix, Linux Find Command,
Search Files, Using Find Command




                                                                      www.thegeekscope.com

More Related Content

Recently uploaded

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Thegeekscope.com find files-in_linux_using_find_command

  • 1. thegeekscope.com http://w w w .thegeekscope.com/find-files-in-linux-using-find- command/ Find Files in Linux using Find Command In Linux, find Command is used to search for specific files and folders. The beauty of the linux find command lies in its ability to perform complex searches. Find command provides plenty of options to specify size, modification date, type, owner, permission while performing a search operation. This article describes some of the most useful options availble with the linux find command with the help of examples. Find Files Based on Filename Pattern Syntax: find <SEARCH_PATH> -type [f|d] -name "<PATTERN>" type ‘f’ indicates that search for files type ‘d’ indicates that search for directories The Geek Scope Example: Search for files in the /root folder which contains the string “monitor” in the filename # find /root -type f -name "*monitor*" /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1 Example: Search for folders in the /root folder which contains the string “monitor” in the foldername # find /root -type d -name "*monitor*" /root/test/test_monitor123 Example: Search for files/folders in the /root folder which contains the string “monitor” in the name # find /root -name "*monitor*" /root/test/test_monitor123 /root/monitor_script.sh /root/monitor_script.sh.v2 /root/monitor_script.sh.v1 www.thegeekscope.com
  • 2. Find Files Based on Modification Time in Days Syntax: find <SEARCH_PATH> -mtime <x> Integer <x> indicates days <x> along with ‘+’ sign indicates, modified before x days <x> along with ‘-’ sign indicates, modified within last x days <x> with no sign indicates, modified exactly x days ago Example: Search /etc folder for files/folders modified exactly 7 days ago # find /etc -mtime 7 Example: Search /etc folder for files/folders modified before 7 days # find /etc -mtime +7 The Geek Scope Example: Search /etc folder for files/folders modified in last 7 days # find /etc -mtime -7 You can use ‘atime‘ in place of ‘mtime’ to find files and folders based on last access time in days. Example: Search /etc folder for files/folders accessed in last 7 days # find /etc -atime -7 Find Files Based on Modification Time in Mins Syntax: find <SEARCH_PATH> -mmin <x> Integer <x> indicates minutes www.thegeekscope.com
  • 3. <x> along with ‘+’ sign indicates, modified before x mins <x> along with ‘-’ sign indicates, modified within last x mins <x> with no sign indicates, modified exactly x mins ago Example: Search /home folder for files/folders modified exactly 60 minutes ago # find /home -mmin 60 Example: Search /home folder for files/folders modified before 60 minutes # find /home -mmin +60 Example: Search /home folder for files/folders modified in last 60 minutes # find /home -mmin -60 You can use ‘amin‘ in place of ‘mmin’ to find files and folders based on last access time in mins. The Geek Scope Example: Search /etc folder for files/folders accessed in last 60 mins # find /etc -amin -60 Find Files Based on Size Syntax: find <SEARCH_PATH> -size <x> Integer <x> indicates size in bytes/kilobytes/megabytes/gigabytes <x> along with ‘+’ sign indicates size larger than x <x> along with ‘-’ sign indicates size smaller than x <x> with no sign indicates, size exactly equal to x Example: Search /etc folder for files/folders having size exactly equal to 20015 bytes www.thegeekscope.com
  • 4. # find /etc -size 20015c Example: Search /root folder for files/folders having size greater than 2 megabytes # find /etc -size +2M Example: Search /home folder for files/folders having size less than 1 kilobytes # find /etc -size -1k Find Files Based on Permissions Syntax: find <SEARCH_PATH> -perm <permission> Example: Search /etc folder for files/folders with permission 755 (read,write,execute for owner and read,execute for group owner and others) The Geek Scope # find /etc -type f -perm 664 Find Empty files and Folders Syntax: find -empty Example: Find all empty files/folders available in a system # find / -empty Find Files Owned by a Specific User Syntax: find <SEARCH_PATH> -user <username> www.thegeekscope.com
  • 5. Example: Find all files/folders owned by user ‘kam’ # find / -user kam Find Files Owned by a Specific Group Syntax: find <SEARCH_PATH> -group <groupname> Example: Find all files/folders owned by group account ‘projectx’ # find / -group projectx Use ‘-and’ and ‘-or’ qualifier to join search patterns Example: Search /root folder for files/folders modified in last 7 days and having size less than 200kB The Geek Scope # find /etc -mtime -7 -and -size -200k Example: Search /home folder for files/folders accessed in last 2 hours or having size greater than 10MB # find /etc -amin -120 -or -size +10M Tagged as: Find Command, Find Files, Find files in LInux, Find files in Unix, Linux Find Command, Search Files, Using Find Command www.thegeekscope.com