Update magic file list and/or submit my own

I love file. I use it multiple times a day. I love it so much that I install Cygwin on my Windows machines just so I can use it. Anyway, in going through older files on my system, I find there are many files that just report “data” from the file command. Understandably.

Some of these files however do have an indicator in their header of what kind of file they are, but are not found in the magic file database yet. My questions are three-fold:

  1. Is there an online repository of magic file definitions that I can use to supplement or update the default ones that came with my OS? (My folder /usr/share/file/magic shows the most recent entry as almost one year ago, and I know people are continually updating these definitions)
  2. How can I submit a new definition that I’ve developed so that the rest of the *nix community can benefit? The online repo?
  3. Is it as simple as dropping the magic definition file in the folder, and my OS will magically find it, or do I have to somehow rebuild the definition library? Do I have to do anything with the magic.mgc file, or just the folder of individual definitions?

Thank you ahead of time for your help.

Asked By: tralston

||

In the past I’ve had changes included in the magic file by submitting a Debian bug report but it’s probably faster to submit them upstream directly.

In answer to your questions:

  1. The latest released source can be found here – there’s a link to a mirror of the source repo there.
  2. Yes, I believe either submitting a bug report or emailing the mailing list should be all that’s needed to add a file definition.
  3. You can create your own magic file and point file file to it by using the -m option.
Answered By: mjturner

About your question 3. :

Try adding your custom definitions to /etc/magic. It will be used alongside the pre-compiled magic.mgc file.

If it doesn’t work, check with

file --version

On my Ubuntu 16.04 system, it reports:

file-5.25
magic file from /etc/magic:/usr/share/misc/magic

So it uses both the /etc/magic text file, and the pre-compiled /usr/share/misc/magic.mgc file

Answered By: mivk
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.