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 ?
Environment
- Red Hat Enterprise Linux (All Versions)
Issue
- I am receiving the following error when trying to
locatea 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.dbdatabase. - Run the
updatedbcommand to recreate themlocate.dbdatabase.
# updatedb
Root Cause
- The main reason is the directory /var/lib/mlocate is empty.
- The
mlocate.dbfile 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