How can I extract “mlocate.db” contents?

Posted on

How can I extract “mlocate.db” contents? – A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about How can I extract “mlocate.db” contents? was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, , , , .

Is it possible to extract the contents of the mlocate.db file to, say, dump it into plain text? Are there any directory or file attributes set for the contents pushed to the database besides the structure mentioned in the man page?

The locate database created by the updatedb command is in essence nothing more than a list of file names. The trivial use case to extract that database is to use a regex or globbing character that matches everything:

locate --database /path/to/mlocate.db *


locate -r .

You can use the command strings on any file to extract all, or at least most of, the plain text in the file, like so:

strings /path/to/mlocate.db >list_of_folders_and_files.txt

The file list_of_folders_and_files.txt will now contain what you’re looking for.

Leave a Reply

Your email address will not be published. Required fields are marked *