File associations – Linux has ’em. Who knew?

Just about any user of Windows is aware (at some level) of its file associations that allow ‘execution’ of data files – that is, the associated application is run which then loads the ‘executed’ data file. This functionality appears to be implemented at a fairly low level; not only can you double click on a file on the desktop or explorer, but you also get the same behavior when ‘executing’ the file from a command line. I suspect that the Windows equivalent of exec() is handling the mapping of extensions to applications and doing the right thing.

Turns out the Linux kernel (since the 2.1 series, 1997ish) also supports the notion of file associations via a loadable module: binfmt_misc. It not only supports invoking an application based on file extension, but also on a magic number. This makes possible atrocities like making MSPaint appear to be a normal Linux program:

In reality, this turns out to be a solution in search of a problem. The hard core users (those that follow The Unix Way) have no need or desire. File management tools have been filling in the gap for everyone else. Nevertheless, it’s there if you need it, and has been for 12 years.


  1. Kendall
    Posted August 18, 2009 at 7:57 am | Permalink

    lol – that smiley looks none too happy about appearing in an instance of mspaint that was invoked in such an unholy way.

  2. jachrispens
    Posted August 18, 2009 at 12:05 pm | Permalink

    Ha… he was definitely surprised at where he woke up. 🙂

Post a Comment

Your email is never shared.