Find to make search of files/folders easy in Linux OS

Find to make search of files/folders easy in Linux OS

Last Blog Review

In the last, blog we understood how awk is such a powerful programming tool which is used as a text processor which means it’s used for extracting the data and manipulating it. Arithmetic operations can be performed like sum, avg, mul, div. Support’s arrays as well. Pattern matching for advanced regex text. Also supports data filtering and transformation.

What is Find in Linux ?

  1. Find is one of the most important and used command in Linux

  2. Find command is used to search and locate list of files and directories based on condition you specify for files that match the arguments.

  3. Find command can be used in variety of conditions like you can use to find files by permission’s, user’s, group’s, file type, date, size, etc.

Let’s understand it practically looking at the commands

  1. To find files under home directory -

    The below command will find the file type have extension as “docx” in home direcctory

     find /home -type f -name "*.docx"
    
  2. To find files with suid permission

     find / -type f -perm /4000
    
  3. To find files with guid permission

     find / -type f -perm /2000
    
  4. To find files with sticky bit permission

     find / -type f -perm /1000
    
  5. Using find command based on user’s

    The find command in Linux can be used to search for files and directories based on the owner (user). You can use the -user option to filter results by user.

     find / -user mihir
    
  6. Using find command based on groups

     find / -group mihirgro
    
  7. Search the file which is less that 10MB

     find / -type f -size -10M
    
  8. Search the file which is more that 10MB

     find / -type f -size +10M
    

Conclusion →

So, here you saw how to use “Find” command in linux, which makes the life easy as there are lot of files and directories in linux because being a inversted tree like structure, it’s very difficult to find a particular find due to which using this command we can get the desired files and directories quickly within no time. As Find allows you to use many filter’s to search the file and directories as we saw above.

Image credit - https://images.app.goo.gl/bgKS3FYdCBcTgRVy8

💡
That’s a wrap for today’s post! I hope this has given you some valuable insights. Be sure to explore more articles on our blog for further tips and advice. See you in the next post!