tdbdump
Dump the contents of a TDB file
SYNOPSIS
tdbdump [-H] [-p] [-s] [-a] <tdb-file>
PARAMETERS
-H
Don't pretty print the data. Output data in raw hexadecimal format, showing the exact bytes stored. This is useful for low-level debugging.
-p
Pretty print the data. This is the default behavior. It attempts to interpret the data and display it in a more human-readable format, often converting ASCII strings where possible.
-s
Show statistics. Displays statistics about the TDB file, such as the number of records, hash chain lengths, and free space. Does not dump the actual records.
-a
Show all records. Includes deleted records in the output. By default, tdbdump only shows active records. Deleted records are often still present in the file until the space is re-used.
The path to the TDB file to be dumped. This is a mandatory argument.
DESCRIPTION
tdbdump is a command-line utility designed to inspect and display the contents of a Trivial Database (TDB) file. TDB is a lightweight, high-performance database library primarily used by Samba to store various types of persistent data, such as share definitions, user information, lock states, and other internal state data. It stores data as key-value pairs.
tdbdump allows administrators and developers to examine the raw data within these files, which can be invaluable for debugging issues, understanding Samba's internal state, or recovering specific pieces of information. It can display data in a human-readable "pretty print" format or as raw hexadecimal output, and can also provide statistics about the database.
CAVEATS
tdbdump is specific to TDB files; it cannot be used for other database formats (e.g., SQLite, MySQL).
The "pretty print" output (using -p) relies on heuristics to determine if data is printable ASCII; binary data might still appear unintelligible.
Examining TDB files while Samba services are running can lead to inconsistent or incomplete output due to concurrent writes, although tdbdump itself is read-only. For consistent dumps, it is recommended to stop relevant Samba services first.
COMMON USAGE EXAMPLES
To view a user database:
tdbdump /var/lib/samba/private/secrets.tdb
To check statistics of a database:
tdbdump -s /var/lib/samba/private/passdb.tdb
To dump raw hexadecimal data for debugging:
tdbdump -H /var/lib/samba/private/share_info.tdb
TDB FILE LOCATIONS
TDB files are typically found in Samba's private directory, often /var/lib/samba/private/ or /var/cache/samba/. Common TDB files include secrets.tdb, passdb.tdb, share_info.tdb, connections.tdb, and locking.tdb.
HISTORY
TDB (Trivial Database) was developed as part of the Samba project to provide a simple, high-performance, and persistent key-value store for internal use. It's designed for concurrent access by multiple processes, making it suitable for services like Samba that manage shared state. tdbdump is an essential part of the TDB utility suite, providing visibility into these critical data files, and has been a staple tool for Samba administrators and developers since TDB's inception.