Why are we getting the error `locate: can not open /var/lib/mlocate/mlocate.db: No such file or directory` when trying to locate a file ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (All Versions)

Issue

  • I am receiving the following error when trying to locate a file:
locate: unexpected EOF reading `/var/lib/mlocate/mlocate.db'
locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory

Resolution

  • The directory /var/lib/mlocate should contain the mlocate.db database.
  • Run the updatedb command to recreate the mlocate.db database.
# updatedb

Root Cause

  • The main reason is the directory /var/lib/mlocate is empty.
  • The mlocate.db file is missing, possibly due to a filesystem check having been run.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments