Results 1 to 4 of 4
hey
i have question !! i want to know how linux recognize file type without extensions ?
in windows every file has its own extension but in linux some file ...
- 07-08-2009 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 3
Extensions
hey
i have question !! i want to know how linux recognize file type without extensions ?
in windows every file has its own extension but in linux some file hasn't any extension but linux can open it with suitable app!!
thanks for answers.
- 07-08-2009 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Most filetypes have a header in the file describing what they are. Windows is no different but sticks with the DOS way of doing things, the file extension.
If you open a terminal you can use the file command to see what properties a particular file has. Have a look at this example, I'm running file againsta CD ISO image.Code:tom@btrprime:~/iso$ file osol-0811.iso osol-0811.iso: ISO 9660 CD-ROM filesystem data 'OpenSolaris ' (bootable) tom@btrprime:~/iso$
- 07-08-2009 #3Just Joined!
- Join Date
- Dec 2008
- Posts
- 3
so...i think windows is a bit faster because windows don't open a file to recognize it's type.(only for showing the filetype not executing the file i mean)
- 07-08-2009 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
No not really, Linux (and all Unix-like systems) achieve this by reading only the first few bytes of a file to retrieve this information. In many cases it'd be less information than even reading the file name!
For example, you may have seen in Linux bash scripts the first line is alwaysThe most important thing there is !#. Those two characters combined represent the information to tell Linux that it is an executable.Code:#!/bin/bash
Have a read about magic numbers and the shebang:
File format - Wikipedia, the free encyclopedia
Shebang (Unix) - Wikipedia, the free encyclopedia
File format - Wikipedia, the free encyclopedia


Reply With Quote