mlocate.db(5)
π mlocate.db β a mlocate database (yes bestie, the binary one)
okay so listen, this page is from mlocate's File Formats Manual, and it's literally about the database file that locate and updatedb pass around like a group chat. no cap, it's giving "receipts for every file on your system." let's get into it π«Ά
πΈ NAME πΈ
mlocate.db β a mlocate database. that's it, that's the name, iconic and to the point π
β¨ DESCRIPTION β¨
so a mlocate database starts with a file header, and it is extremely particular about its bytes, okay? like, she has a whole routine:
- 8 bytes for a magic number β
"\0mlocate"like a C literal β¨ - 4 bytes for the configuration block size in big endian (yes, big endian, she's fancy)
- 1 byte for file format version β that's
0 - 1 byte for the "require visibility" flag β either
0or1 - 2 bytes padding (she just needs a little breathing room)
- a NUL-terminated path name of the root of the database π
the header is followed by a configuration block. and why, you ask? because databases should not be reused if some configuration changes could affect their contents β like, imagine a database from a whole different config era showing up, embarrassing π so the size of the configuration block in bytes is stored right there in the file header.
the configuration block is a sequence of variable assignments, ordered by variable name. each assignment is:
- a NUL-terminated variable name
- an ordered list of NUL-terminated values
- the value list is terminated by one more NUL character
the ordering used is defined by the strcmp () function β so alphabetical-ish, but technically strcmp-ish, iykyk.
π¦ Currently defined variables π¦
prune_bind_mountsβ a single entry, the value ofPRUNE_BIND_MOUNTS; one of the strings0or1.prunefsβ the value ofPRUNEFS, each entry converted to uppercase.prunepathsβ the value ofPRUNEPATHS.
the rest of the file until EOF describes directories and their contents, and this part is where it gets juicy.
each directory starts with its own header:
- 8 bytes for directory time (seconds) in big endian
- 4 bytes for directory time (nanoseconds) in big endian β
0if unknown, and it's always less than1,000,000,000 - 4 bytes padding (again with the padding, she's consistent)
- a NUL-terminated path name of the the directory (yes, "the the," the original says it, I'm not fixing it, that's her voice π)
after the header comes the directory contents β a sequence of file entries sorted by name. main character energy from start to finish π
directory time is the maximum of st_ctime and st_mtime of the directory. updatedb(8) uses the original data if the directory time in the database and in the file system match exactly. but watch out: directory time equal to 0 always causes rescanning of the directory β this is necessary to handle directories which were being updated while building the database. no shortcuts, bestie.
π File entry types (the little byte that tells you everything) π
each file entry starts with a single byte, and that byte is the whole personality:
0β a non-directory file. followed by a NUL-terminated file (not path) name.1β a subdirectory. followed by a NUL-terminated file (not path) name.2β marks the end of the current directory.
and real talk: locate(1) only reports file entries, directory names are not reported because they are reported as an entry in their parent directory. the only exception is the root directory of the database, which is stored in the file header. so the root is the one main character who gets her own header spot, periodt π
π AUTHOR π
Miloslav Trmac <mitr@redhat.com> β the icon who made this whole byte party happen, we stan π
π SEE ALSO π
okay that's the whole vibe check, bestie. go forth and read those bytes like the icon you are. and remember: mlocate, Jan 2007 β that's the source and date of this legendary manual page, so show her some respect πβ¨
π¦ where this page comes from
- alpine 3.24: mlocate-doc 0.26-r9 Β· GPL-2.0-only
- centos-stream 9: mlocate 0.26-31.el9 Β· GPLv2
- nixos 26.05: mlocate 0.26
- nixpkgs unstable: mlocate 0.26
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mlocate 0.26-160000.3.2 Β· GPL-2.0-only
- Copyright (C) 2005, 2007 Red Hat, Inc. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms