• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

What’s the difference between locate and find command in Linux

by admin

Two popular commands for locating files on Linux are find and locate. Depending on the size of your file system and the depth of your search, the find command can sometime take a long time to scan all of the data. For example, if you search your entire filesystem for the files named data.txt:

# find / -name data.txt

More likely than not, this will take on the order of minutes, if not longer to return. A quicker method is to use the locate command:

# locate data.txt

However, this efficiency comes at a cost, the data reported in the output of locate isn’t as fresh as the data reported by the find command. By default, the system will run updatedb which takes a snapshot of the system files once a day, locate uses this snapshot to quickly report what files are where. However, recent file additions or removals (within 24 hours) are not recorded in the snapshot and are unknown to locate.

The find command has a number of options and is very configurable. There are many ways to reduce the depth and breadth of your search and make it more efficient.

locate uses a previously built database, If database is not updated then locate command will not show the output. to sync the database it is must to execute updatedb command.

# updatedb
Linux / UNIX : Examples of find command to find files with specific sets of permissions

Filed Under: Linux

Some more articles you might also be interested in …

  1. md5sum Command Examples in Linux
  2. dconf Command Examples in Linux
  3. setxkbmap: command not found
  4. loc Command Examples
  5. nixos-rebuild Command Examples in Linux
  6. “go tool” Command Examples
  7. asterisk: command not found
  8. hardhat Command Examples
  9. dig: DNS lookup utility
  10. autoconf: Generate configuration scripts to automatically configure software source code packages

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright