Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As the question goes, how does Ubuntu know what file type a file without extension is?

When I save a file as "Untitled Document" without any extension, how does it know? Same thing for video and music formats...

share|improve this question
    
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 –  Tachyons Feb 28 '12 at 19:10
add comment

1 Answer

up vote 29 down vote accepted

Via "magic"

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.

http://linux.die.net/man/5/magic

http://linux.die.net/man/1/file

share|improve this answer
4  
Well you weren't kidding about the magic now were you Houdini. Thanks Amazing Zazen! –  Luis Alvarado Feb 28 '12 at 19:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.