4

I have a PDF file with extension .pdf. If I remove .pdf - the file is still recognized as PDF file ($ file sample - output sample: PDF document, version 1.4.)

What is the mechanism of filetype detection in Linux? Windows uses file suffix. I know that there are mime types. Does all popular file formats contain their mimetype in HEX code?

yanpas
  • 257
  • 1
  • 10

1 Answers1

5

The detection is done through libmagic which looks for specific byte sequences with magic numbers.

don_crissti
  • 79,330
  • 30
  • 216
  • 245
Jesusaur
  • 329
  • 1
  • 7