The interestingly named configuration for the common unix and very useful command, file. This file contains the magic bytes that are used to identify the type of data in a file. For example, MS-DOS executables are identified by the string "MZ" occurring in the first two bytes. The OpenBSD version of the /etc/magic uses this information to identify DOS EXE files, as shown below:

# .EXE formats (Greg Roelofs,
0       string  MZ              MS-DOS executable (EXE)
>24     string  @               \b, OS/2 or Windows
>1638   string  -lh5-           \b, LHa SFX archive v2.13S
>7195   string  Rar!            \b, RAR self-extracting archive

With /etc/magic, a file's header data can identify a file type when the file name has been changed or lost. However, not all data files have sensible headers. When this occurs, the "file" command cannot identify the source of the file.

Log in or register to write something here or to contact authors.