Linux trick turns SQLite database file into directly executable binary
Developer Farid Zakaria has demonstrated a Linux technique that stores ELF executable components inside a SQLite database and runs the file directly as a binary.

👁 121 reads
Developer Farid Zakaria has demonstrated a Linux technique that stores the components of an ELF executable inside a SQLite database file and allows that file to be run directly as a binary, as highlighted by Simon Willison on 24th August 2026.
- The trick sets the 4-byte application ID at offset 68 in a SQLite file to SELF, standing for Structured Executable & Linkable Format
- ELF binary components are stored across multiple SQLite tables; a C interpreter called self-exec extracts and runs them
- Linux's binfmt_misc mechanism can be registered to let the kernel automatically recognise and execute any file matching that binary pattern
The mechanism exploits a largely overlooked field in the SQLite file format: a 4-byte application ID located 68 bytes into the file. Zakaria sets that field to the ASCII string SELF, which he defines as Structured Executable & Linkable Format. The various components that make up a standard ELF binary - the format Linux uses for executables - are then arranged into a set of SQLite tables using a defined schema.
A small C program called self-exec acts as the interpreter: it opens the SQLite file, reads the relevant tables, and extracts and runs the executable pieces. The project’s C source code is publicly available alongside the schema.
To make the kernel handle these files automatically, Zakaria registers the pattern with Linux’s binfmt_misc facility, which lets the OS delegate execution of any file matching a given binary signature to a nominated interpreter. On NixOS, where Zakaria works, this is handled through the system configuration. On a generic Linux system, Willison notes, registration requires writing a rule string to /proc/sys/fs/binfmt_misc/register pointing the SELF magic bytes at the /usr/local/bin/self-exec binary.
The result is a single .sqlite file that is simultaneously a valid, queryable database and a directly runnable program - no wrapper script needed.
Practitioner note: For developers building or packaging AI tools on Linux, this pattern points toward a concrete way to bundle an executable together with structured metadata - configuration tables, model parameters, logs - in one inspectable file. SQLite’s read performance and its availability as a zero-dependency library mean the overhead is low, and the file stays queryable with standard tools even after deployment.
Google · Your sourcesQuantslant higher in your Google - one clickAdd to preferred sources →More on this from QUANTSLANT
news·AI Developers Reconsider as Claude Fable’s Cost Outweighs Gains

