Each type of file have it is on bit arrangement
so the type of file can be determined by this pattern
else
some metadata also helpful to detect file type
still ubuntu cant understand filetype of most of the files without extension – TachyonsFeb 28 '12 at 19:10
The file(1) command identifies the type of a file using, among other tests, a test for whether the file contains certain ''magic patterns''. The file /usr/share/misc/magic specifies what patterns are to be tested for, what message or MIME type to print if a particular pattern is found, and additional information to extract from the file.