I use file extensions for a number of reasons. In many cases, this is to save me working around the issues resulting from not using an extension. There are few cases were not using an extension provides an advantage, mainly when running a program.
In Unix/Linux file extensions don't have meaning when it comes to executing a file. This is controlled by the executable bit. The interpreter for scripting languages is specified in the first line using a bang path such as
For executable files in standard directories, it is standard practice to omit the extension. However, it is also common to use extensions for locally written scripts. This is helpful when searching for an example or common practice in a particular scripting language.
For non-executable files the extension provides valuable type information both user and programs that read them. Web servers use the file extension extensively in determining the file type, and thus what headers to apply. Compilers and programmers rely on the extensions to determine the file types.
Some tools will use
magic files to determine the file type based on the file contents. Many file types contain
magic values at known locations, and these can be used to reliably guess the file type in many cases. Other tools will just open a file assuming it is an appropriate file. This allows you to play text files or text edit pictures, although neither are recommended.
Within classifications of files there are often incompatible types which are normally indicated by the extension:
- Pictures: bmp, jpeg, gif, png, tiff...
- Videos: mpg, rm, flv, wmv...
- Sound: mp3, ogg, wav...
- Documents: html, txt, pdf, rtf, doc...
While some tools can handle multiple formats, others will fail with one or more types. Omitting the file extension will likely lead you to use the wrong tool to open some files.
There are also cases where there are multiple related files are differentiated by the extension. For example a program
foobar written in
c may result from the files