This is the home page for the open source implementation of the file(1) command that ships with most free operating systems (Linux, NetBSD, FreeBSD, etc.) and has been ported to most systems where people use free software (including DOS, MS Windows, OS/2 (remember that?), etc.). The lone standout, OpenBSD, wrote their own code, but still use our file command’s configuration files. My code was also used in a file typing module in the Apache Web Server.
What?
The file command is "a file type guesser", that is, a command-line tool that tells you in words what kind of data a file contains. Unlike most GUI systems, command-line *NIX systems - with this program leading the charge - don’t rely on filename extentions to tell you the type of a file, but look at the file’s actual contents. This is, of course, more reliable, but requires a bit of I/O.
The original file command shipped with Bell Labs UNIX (here is a man page from Research 4th Edition, 1973, obtained from the The Unix Historical Society), but was unavailable in source form to the masses before Ian’s reimplementation.
This file command (and magic file) was originally written by Ian Darwin (who still contributes occasionally) and is now maintained by a group of developers lead by Christos Zoulas. Announcements of new releases are made on the "file" mailing list.
Who’s using it?
-
Most known BSD distributions (FreeBSD, NetBSD, Darwin/Mac OS X, etc)
-
Every known Linux distribution
LibMagic?
Originally written as a self-contained program, it has since been split into a main program and a library, libmagic, to allow its use in other programs. One example of libmagic is its use in Python via the file module.
Got code?
The file program is included in most UNIX systems today.
Should you want or need to compile it yourself, or just want to see how it works, you’ll find the latest released version of the file command’s source code at ftp://ftp.astron.com/pub/file/.
Should you prefer to go more bleeding edge, there’s a read-only mirror of the project’s internal CVS repository on github.
Forty Years Before the File
My first commit in RCS, before the repository was migrated into a CVS repository, and then to git, was in August, 1987:
revision 1.1 date: 1987/08/23 19:51:05; author: ian; state: Exp; Initial revision
Bugs
Please report bugs to the bug tracker or the mailing list (see above).
Derivative Implementations
-
The Apache httpd server mod_mime_magic module uses the file command’s innards to make file type guessing more reliable under Apache HTTPD.
-
The OpenBSD project wrote their own implementation because they found Christos' version of my implementation to have grown too big and complex; they still use our Magic Files.
-
SimplMagic is a Java implementation that uses our Magic Files. Home GitHub Maven
Alternate file-typing programs:
-
Droid, a UK government (national archives) program, in Java, using its pronom database of file formats.