Where to Find and Completely Remove updatedb Database in Debian Squeeze: A Developer’s Guide


4 views

In Debian Squeeze (and most Linux distributions), the updatedb database is typically stored at:

/var/lib/mlocate/mlocate.db

This is the central database file used by the locate command. The mlocate.db file contains the indexed file paths that allow for fast searching.

To completely remove locate and its database, follow these steps:

# First remove the package
sudo apt-get purge mlocate

# Then remove any remaining files
sudo rm -f /etc/updatedb.conf
sudo rm -f /etc/cron.daily/mlocate
sudo rm -f /var/lib/mlocate/mlocate.db

# Optional: cleanup any empty directories
sudo rmdir /var/lib/mlocate 2>/dev/null

After performing these steps, verify that all components are removed:

# Check for package
dpkg -l | grep mlocate

# Check for database file
ls -la /var/lib/mlocate/mlocate.db 2>/dev/null

# Check for cron job
ls -la /etc/cron.daily/mlocate 2>/dev/null

If you want to reinstall the package cleanly:

sudo apt-get install mlocate

The system will automatically create a new empty database at /var/lib/mlocate/mlocate.db and set up the daily cron job to update it.

If you prefer to manually control when the database is updated rather than using the daily cron job:

# Remove the cron job
sudo rm /etc/cron.daily/mlocate

# Run updatedb manually when needed
sudo updatedb

This gives you more control over when the filesystem is scanned, which can be useful on systems with limited resources.


On Debian-based systems including Squeeze, the locate database is typically stored at:

/var/lib/mlocate/mlocate.db

This is the primary database file that gets updated by the updatedb cron job. The configuration files for updatedb are usually found in:

/etc/updatedb.conf
/etc/cron.daily/mlocate

To fully purge locate and its database from your Debian system:

# Remove the package and configuration files
sudo apt-get purge mlocate

# Manually remove any remaining database files
sudo rm -f /var/lib/mlocate/mlocate.db
sudo rm -f /etc/updatedb.conf
sudo rm -f /etc/cron.daily/mlocate

After running these commands, verify no locate-related files remain:

# Check for package remnants
dpkg -l | grep mlocate

# Search for remaining files
sudo find / -name "*mlocate*" -o -name "*updatedb*"

To reinstall locate with a fresh database:

sudo apt-get update
sudo apt-get install mlocate

# Force immediate database update
sudo updatedb

After reinstalling, you may want to configure /etc/updatedb.conf to exclude certain paths:

PRUNEPATHS="/tmp /var/spool /media"
PRUNEFS="NFS nfs afs smbfs autofs"

The database is updated daily via cron. Check the cron job:

ls -l /etc/cron.daily/mlocate
cat /etc/cron.daily/mlocate

To modify the update frequency, create a custom cron job in /etc/cron.d/.

If you encounter issues after reinstallation:

# Check database freshness
ls -lh /var/lib/mlocate/mlocate.db

# Test locate functionality
locate updatedb | head -5

# View update logs
grep mlocate /var/log/syslog