Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q1246 What does the file extension mean?

You are here: irt.org | FAQ | Linux | Q1246 [ previous next ]


Well that's not entirely true, but the 'system' does not rely on the names of files, but some programs can and do use the extention as a hint at what type it may be. Any file can be made executable with the chmod command. If you write a program (binary or script) then to 'run it' you'll need to then do 'chmod u+x' (which sets it executable by the owner of that file).

When you tell the system to run a file that is executable, then the first few bytes of the file are examined to decide how it is to be run. Files like ELF/Java binaries will be handled by the kernel directly, and text files that start with something like "#! /path/to/some/interpreter" (often called the 'shebang line'), cause the interpreter to be executed and then the text file be used as the source code. (eg. Perl, Shell scripts, Python, tcl)

If it isn't a valid binary, and it doesn't have a shebang line, then the lines will be passed to the current shell (probably bash). So you can be lazy and not use a shebang line if you always use the same shell, but it is good practice to start your Bourne-Again-SHell scripts with #! /bin/bash

To find out information about a file, then use the 'file' command. (see 'man file' and 'man magic' for more info ) eg. try these...

file /bin/bash
file /etc/rc.d/rc.sysinit
file /usr/share/icons/xv.xpm

OK, your paths might not be the same as mine, but you get the point.

For data files, there is a huge number of different types of naming conventions used to hint at what type it might be, and some programs like mc (midnight commander - a file manager) use these to decide what program to use to view it etc....

Take a look at the file /etc/mime.types for a list of common extentions.

©2018 Martin Webb