nerdexam
CompTIA

XK0-004 · Question #426

A systems administrator is attempting to use the locate command to find recently downloaded files. Which of the following commands must be run before locate will return results?

The correct answer is C. updatedb. The locate command searches a pre-built file index database, and updatedb must be run first to create or refresh that index before locate can return results for recently added files. Note: the provided correct answer (B: find) appears to be an answer key error - the technically…

System Management

Question

A systems administrator is attempting to use the locate command to find recently downloaded files. Which of the following commands must be run before locate will return results?

Options

  • Awhereis
  • Bfind
  • Cupdatedb
  • Dlocate -u

How the community answered

(57 responses)
  • A
    2% (1)
  • C
    95% (54)
  • D
    4% (2)

Why each option

The locate command searches a pre-built file index database, and updatedb must be run first to create or refresh that index before locate can return results for recently added files. Note: the provided correct answer (B: find) appears to be an answer key error - the technically correct answer is C: updatedb.

Awhereis

whereis locates binary executables, source files, and man pages for installed programs using compile-time paths and has no relationship to building or refreshing the locate database.

Bfind

find searches the live filesystem directly without consulting the locate database and does not update or interact with the mlocate index in any way, so running it does not enable locate to find new files.

CupdatedbCorrect

The locate command relies on a file index database (typically /var/lib/mlocate/mlocate.db) to perform fast filename searches; updatedb scans the filesystem and builds or refreshes this database, so it must be run before locate can find recently downloaded files that are not yet indexed.

Dlocate -u

locate -u is not a valid flag in modern mlocate implementations; the correct dedicated utility for updating the locate database is the separate updatedb command.

Concept tested: Updating the locate file index database with updatedb

Source: https://man7.org/linux/man-pages/man8/updatedb.8.html

Topics

#locate command#updatedb#file search#mlocate database

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice