Find and Locate

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 10:18, 28 March 2019 by Admin (Talk | contribs)

Jump to: navigation, search

Find and Locate - Searching for files in Linux

  • The find command works without the need to build a metabase
  • The locate command is much faster but depends on a metabase
  • find it typically present on any linux system while locate is part of mlocate which needs installed
  • find results are real-time, recent changes to the file system is not a problem
  • locate requires you run 'updatedb' to rebuild the metabase before recent changes on the file system can be searched

Find

Use the find command to search for a file or pattern.

here are examples:

  find ./ -name filename   (locate filename in or below the
  current directory path)
  find / -name 'filename' 2>/dev/null   (locate filename 
  anywhere up from root filesystem)
  find ./ -iname 'filen*'   (locate all files begin with
  filen and ignore case)

Locate