The magic tests are used to check for files with data in particular fixed formats. The canonical example of this is a binary executable (compiled program)
a.outfile, whose format is defined in
#include <a.out.h>and possibly
#include <exec.h>in the standard include directory. These files have a 'magic number' stored in a particular place near the beginning of the file that tells the UNIX operating system that the file is a binary executable, and which of several types thereof. The concept of a 'magic' has been applied by extension to data files. Any file with some invariant identifier at a small fixed offset into the file can usually be described in this way. The information identifying these files is read from the compiled magic file
/usr/share/misc/magic.mgc, or the files in the directory
/usr/share/misc/magicif the compiled file does not exist. In addition, if
$HOME/.magicexists, it will be used in preference to the system magic files. If
/etc/magicexists, it will be used together with other magic files.
Fair enough. So if, by coincidence, a text file happens to contain a 'magic number' specific to, for example, an
mp4 video at an appropriate offset… Will double-clicking such a text file result in a video player being launched instead of a text editor?