UPDATE-BINFMTS(8)
β¨ update-binfmts β¨
okay bestie, gather round π this is update-binfmts, a section 8 (system administration) manual page, and she's here to help you keep a whole registry of executable binary formats. no cap.
π SYNOPSIS π
update-binfmts [options] --install name path spec
update-binfmts [options] --remove name path
update-binfmts [options] --import [name]
update-binfmts [options] --unimport [name]
update-binfmts [options] --display [name]
update-binfmts [options] --enable [name]
update-binfmts [options] --disable [name]
update-binfmts [options] --find [path]
π¦ DESCRIPTION π¦
so, versions 2.1.43 and later of the Linux kernel have contained the binfmt_misc module. and what that lil icon does is let a system administrator register interpreters for all sorts of binary formats β based on a magic number, or based on their file extension β and then whenever a matching file gets executed, the appropriate interpreter gets invoked. periodt.
think of it as a more flexible version of the #! executable interpreter mechanism, or as something that can behave a little like "associations" in certain other operating systems (though in GNU/Linux the tendency is to keep this sort of thing somewhere else, like your file manager π). update-binfmts manages a persistent database of these interpreters.
when each package providing a registered interpreter is installed, changed, or removed, update-binfmts is called to update information about that interpreter. and usually? update-binfmts is called from the postinst or prerm scripts in Debian packages. π
πΈ OPTIONS πΈ
exactly one action must be specified; this may be accompanied by any one of the common options. yes bestie, one action. not two. one. π«Ά
β COMMON OPTIONS β
--packagepackage-name β specifies the name of the current package, to be used by package post-installation and pre-removal scripts. system administrators installing binary formats for local use should probably ignore this option, ngl. when installing new formats, the--importaction should be used instead. similarly, when removing old formats, the--unimportaction should be used instead.--admindirdirectory β specifies the administrative directory, when this is to be different from the default of/var/lib/binfmts.--importdirdirectory β specifies the directory from which packaged binary formats are imported, when this is to be different from the default of/usr/share/binfmts.--testβ don't do anything, just demonstrate what would be done. it's giving dress rehearsal π--helpβ display some usage information.--versionβ display version information.
π ACTIONS π
--installname path spec β install a binary format identified by name with interpreter path into the database. after registration, this format will be used when the kernel tries to execute a file matching spec (see βBINARY FORMAT SPECIFICATIONSβ below).--installwill attempt to enable this binary format in the kernel as well as adding it to its own database; see--enablebelow.
you cannot install a format with any of the names".","..","register", or"status", as these are used by the filesystem or thebinfmt_miscmodule. so like, don't even try it π
--removename path β remove the binary format identified by name with interpreter path from the database. this will also attempt to disable the binary format in the kernel; see--disablebelow.--import[name] β import a packaged format file called name, or import all format files currently on the system if no name is given. if name is not a full path, it is assumed to be a file in the import directory (/usr/share/binfmtsby default). see βFORMAT FILESβ below for the required contents of these files. for packages, this is preferable to using the--installoption, as a format file can be installed withoutupdate-binfmtsneeding to be available. lowkey genius β¨--unimport[name] β unimport a packaged format file called name, or unimport all format files currently on the system if no name is given. if name is not a full path, it is assumed to be a file in the import directory (/usr/share/binfmtsby default). see βFORMAT FILESβ below for the required contents of these files. for packages, this is preferable to using the--removeoption, for symmetry with--import. we love symmetry πͺ--display[name] β display any information held in the database about the binary format identifier name, or about all known binary formats if no name is given. also show whether displayed binary formats are enabled or disabled.--enable[name] β enable binary format name, or all known binary formats if no name is given, in the kernel, thus enabling direct execution of matching files. you must havebinfmt_misccompiled into the kernel or loaded as a module for this to work.--disable[name] β disable binary format name, or all known binary formats if no name is given, in the kernel, thus disabling direct execution of matching files. you must havebinfmt_misccompiled into the kernel or loaded as a module for this to work.--find[path] β print the list of interpreters that will be tried in sequence when attempting to execute path, one per line. the first one for whichexecvp(3)succeeds will be used.
note that if multiple formats match an executable, then the order is in general not defined, and may not be preserved between update-binfmts operations, so you should generally try to ensure that this option prints at most one line for any given path. the exception to this is that any format with a userspace detector will be run before any format without a userspace detector. π
π BINARY FORMAT SPECIFICATIONS π
--magicbyte-sequence β this matches all files with the magic number byte-sequence. hexadecimal escapes may be included in the byte-sequence by preceding them with\x, for example'\x0a'for a linefeed. remember to protect such escapes with quotes or an additional backslash to prevent their interpretation by the shell. π also see--offsetand--mask.--offsetoffset β this is the offset of the magic/mask in the file, counted in bytes. the default is0. only valid with--magic.--maskbyte-sequence β this mask will be logically-ANDed with the string to be checked against the magic number given with--magic. the default is all0xff, i.e. no effect. only valid with--magic.--extensionextension β this matches all files whose names end in".extension". hexadecimal escapes are not recognized here. extension matching is case-sensitive. π--detectorpath β if this option is used, a userspace detector program will be used to check whether the file is suitable for this interpreter. this may be used when the binary format is more complex than can be handled by the kernel's format specifications alone. the program should return an exit code of zero if the file is appropriate and non-zero otherwise. this option cannot be used together with--fix-binary yes.--credentials yes,--credentials noβ whether to keep the credentials of the original binary to run the interpreter; this is typically useful to run setuid binaries, but has security implications. β οΈ--preserve yes,--preserve noβ whether to preserve the originalargv[0]when running the interpreter, rather than overwriting it with the full path to the binary.--fix-binary yes,--fix-binary noβ whether to open the interpreter binary immediately and always use the opened image. this allows the interpreter from the host to be used regardless of usage in chroots or different mount namespaces. the default behaviour isno, meaning that the kernel should open the interpreter binary lazily when needed. this option requires Linux4.8or newer. it cannot be used together with--detector, or with multiple binary formats that share the same magic number, since the kernel will only open a single interpreter binary which will then not be able to detect and execute the real interpreter from inside a chroot or from a different mount namespace. π
π FORMAT FILES π
a format file is a sequence of options, one per line, corresponding roughly to the options given to an --install command. each option consists of a key, followed by whitespace, followed by a value.
the package option should be set to the current package. the interpreter option should be set to the path to the interpreter that will handle this binary format. the magic, offset, mask, extension, detector, credentials, preserve, and fix_binary options correspond to the command-line options of the same names. slay β¨
π EXIT STATUS π
0β the requested action was successfully performed. we love a happy ending π₯³2β problems were encountered whilst parsing the command line or performing the action. π
π§ EXAMPLES π§
this format file can be used with an interpreter capable of handling Java .class files:
package javawrapper
interpreter /usr/bin/javawrapper
magic \xca\xfe\xba\xbe
this corresponds roughly to the following command:
update-binfmts --package javawrapper \
--install javawrapper /usr/bin/javawrapper \
--magic '\xca\xfe\xba\xbe'
π NOTES π
if you're not careful, you can break your system withupdate-binfmts. an easy way to do this is to register an ELF binary as a handler for ELF, which will almost certainly cause your system to hang immediately; even if it doesn't, you won't be able to runupdate-binfmtsto fix it. π
in the future update-binfmts may have some checks to prevent this sort of thing happening accidentally, though of course you can still manipulate the binfmt_misc kernel module directly. main character energy, dangerous main character energy.
π AUTHOR π
update-binfmts is copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Colin Watson <cjwatson@debian.org>. see the GNU General Public License version 3 or later for copying conditions.
you can find the GNU GPL v3 in /usr/share/common-licenses/GPL-3 on any modern Debian system. π
Richard Guenther wrote the binfmt_misc kernel module. iconic of him honestly.
π«Ά THANKS π«Ά
Ian Jackson wrote update-alternatives and dpkg-divert, from which this program borrows heavily. shoutout king π
and that's the whole page bestie!! brought to you by the Debian crew, dated January 24, 2011, living in the LOCAL section of your man pages. go forth and register your binary formats responsibly πβ¨
π¦ where this page comes from
- debian bookworm: binfmt-support 2.2.2-2 Β· GPL-3.0-or-later
- debian trixie: binfmt-support 2.2.2-7 Β· GPL-3.0-or-later
- ubuntu jammy: binfmt-support 2.2.1-2 Β· GPL-3.0-or-later
- ubuntu noble: binfmt-support 2.2.2-7 Β· GPL-3.0-or-later
- ubuntu resolute: binfmt-support 2.2.2-8 Β· GPL-3.0-or-later
- ubuntu stonking: binfmt-support 2.2.2-8 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms