Home > Package & System Management > updatedb

updatedb: Update locate database

The `updatedb` command creates or updates the index database of the file system, allowing the `locate` command to find files quickly. This database is typically stored at `/var/lib/mlocate/mlocate.db` and contains information about file paths across the entire system. `updatedb` is usually run periodically by system administrators or set up to run automatically via `cron` jobs.

Overview

`updatedb` is an essential utility for keeping the file database used by the `locate` command up-to-date. If this database is not updated, `locate` will not be able to find recently added or modified files. It generally needs to be run with `root` privileges to scan and index all file systems.

Key Features

  • Creates/updates the database for the `locate` command
  • Scans the entire system's file system
  • Typically run automatically via `cron` jobs
  • Allows specifying paths/file systems to exclude from scanning via the configuration file (`/etc/updatedb.conf`)

Main Options

The `updatedb` command is usually run without options or with specific options within `cron` scripts. Most configurations are done in the `/etc/updatedb.conf` file.

General Options

Generated command:

Try combining the commands.

Description:

`updatedb` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

The `updatedb` command is typically run with `sudo` to scan the entire system's file system.

Basic Database Update

sudo updatedb

The most common usage to update the `locate` database. This command requires `root` privileges.

Update with Progress Display

sudo updatedb -v

Use the `-v` (verbose) option to see the database update process in detail.

Installation

`updatedb` is usually part of the `mlocate` package. It may not be installed by default on most Linux distributions, so you can install it using the following commands if needed.

Debian/Ubuntu Based Systems

sudo apt update
sudo apt install mlocate

CentOS/RHEL/Fedora Based Systems

sudo yum install mlocate

Tips & Considerations

Points to note and tips related to performance and security when using `updatedb`.

Performance and Resources

  • Execution Time: The execution of `updatedb` can take a significant amount of time depending on the number and size of files on your system. It is generally recommended to run it via a `cron` job during off-peak hours, such as early morning.
  • CPU/Disk Usage: It can consume significant CPU and disk I/O while scanning the file system, which may affect other system operations.

Security and Configuration

  • Root Privileges: `updatedb` must be run with `root` privileges to index all files on the system. Running it with regular user privileges may result in only a subset of files being indexed.
  • Configuration File: The behavior of `updatedb` can be finely controlled through the `/etc/updatedb.conf` file. For example, you can use the `PRUNEPATHS` variable to exclude specific directories (e.g., `/tmp`, `/proc`, `/sys`, `/dev`, `/mnt`, `/media`) from scanning, or the `PRUNEFS` variable to exclude certain file system types (e.g., `nfs`, `cifs`, `fuse`). This helps improve performance and security.
  • Database Location: The generated database file is typically stored at `/var/lib/mlocate/mlocate.db`. This file is used by the `locate` command.


Same category commands