File type recognition

File extension

The method is simple, unsafe

Binary file header

Magic number (as programmed in the magic number), referred to herein as the first four bytes of two file mechanisms. Different file types, four different bytes Content

For .class files, also followed behind the magic number used java version information

Of course, some of the magic number of the file (the first four bytes) content is not fixed, it needs (two mechanisms contents of the intermediate file or the contents of two mechanisms end of a location, etc.) to identify other ways

Use software to identify: File command

How to understand and identify the types of files in Linux

reference:

https://www.hollischuang.com/archives/491

Guess you like

Origin www.cnblogs.com/shengulong/p/11647332.html