Ubuntu systemd timers run routine background services to keep system documentation, command references, and manual pages searchable. The man-db.service and its scheduled trigger man-db.timer scan for new package documentation and update index caches in /var/cache/man. When running systemctl --failed reports that man-db.service has entered a failed state with non-zero exit codes, repairing broken index caches and file permissions restores documentation lookup commands like man, whatis, and apropos.
Why Does the man-db Service Fail in Ubuntu?
The systemd unit executes /usr/bin/mandb --quiet to compile manual page index trees:
- Corrupted Berkeley DB (or GDBM) Database: Stale index binary files corrupted during an unexpected server reboot or kernel crash.
- Incorrect File Ownership on /var/cache/man: File permissions modified from the dedicated
man:manservice account to root or standard user. - Broken Manual Symlinks from Uninstalled Packages: Orphaned documentation links in
/usr/share/man/pointing to non-existent targets, causing the mandb parser to abort. - Exhausted Inodes or Storage on /var: The filesystem lacking available blocks to write the new index table.
1. Check Systemd Journal Logs for the Mandb Failure
Querying the journal pinpoints the exact file path or database error causing mandb to exit.
- Open your terminal and run:
sudo journalctl -u man-db.service -n 50 --no-pager - Review the error messages:
mandb: can't create index cache /var/cache/man/...: Permission or disk space failure.mandb: fatal: corrupted database: Damaged index file structure.mandb: warning: /usr/share/man/... is a dangling symlink: Orphaned documentation link.
2. Verify Storage Space and Inode Availability
A full root or /var partition prevents mandb from completing temporary file writes.
- Check available disk space:
df -h /var/cache/man - Check inode usage:
df -i /var - If the volume is full, clean up old APT package archives:
sudo apt-get clean && sudo apt-get autoremove --purge -y
3. Purge Corrupted Index Files and Fix Directory Permissions
Removing corrupted index caches allows mandb to create fresh binary databases.
- Stop any running manual services:
sudo systemctl stop man-db.service - Delete all cached index files:
sudo rm -rf /var/cache/man/* - Restore official Ubuntu ownership and permissions:
sudo chown -R man:man /var/cache/man sudo chmod 755 /var/cache/man
4. Force a Complete Manual Database Rebuild
Execute mandb with the creation flag to rebuild every manual index catalogue cleanly.
- Run the manual database rebuild command:
(Thesudo mandb -c-cparameter forces the tool to create databases from scratch rather than updating existing ones). - Watch the terminal output as it processes standard manual paths (
/usr/share/man,/usr/local/man). - Confirm that
/var/cache/man/index.dbwas generated with a valid file size:ls -lh /var/cache/man/index.db
5. Reset Systemd Failure State and Restart Service
Clear systemd failure flags and verify successful execution.
- Reset the failure state:
sudo systemctl reset-failed man-db.service - Manually start the service to verify it finishes cleanly:
sudo systemctl start man-db.service - Check status to confirm an active/exited success code:
sudo systemctl status man-db.service - Verify that the scheduled companion timer is waiting for the next daily interval:
sudo systemctl status man-db.timer