Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Knowing file extensions really helps to understand what a program is doing or using. What are some common one's and how do I extract them?

share|improve this question
Newbie questions spree tonite, @wojox ? In an OS where file extentions play little role, its quite "weird" to ask about the common ones, specially since most are inherited from Windows. – MestreLion Jun 10 '11 at 14:46
up vote 8 down vote accepted

File extension are up to the creator of the file. In Linux you can name something music.mp3 but if it is a text file it will open with gedit if that is your texteditor because it will look at the 1st bit/byte(?) where it says what kind of file it is.

When it comes to bash script it is considered best practise to not include .sh at the end. By omitting it you basically create a command so those do not tend to even have an extension. And those commands could be made in bash but also in perl or python.

So looking at the actual name of the file might be misleading!

Linux has a command file to find out what a file is. Syntax file *
Some random samples:

xxxx.sql:    UTF-8 Unicode text, with very long lines
xxxx.sql.gz: gzip compressed data, was "xxxx.sql", from Unix, last modified: 
             Wed May 18 10:21:34 2011
yyyyy:       ASCII text
iffffff:     directory
ghgggg.tar:  POSIX tar archive (GNU)   perl script text executable

For a list of extensions Fuddledumpy's post can be used and files ending on .pl will more than likely be perl scripts but to make sure use file.

share|improve this answer
So why does screenshot.png.odf: PNG image data, 601 x 317, 8-bit/color RGB, non-interlaced open in LibreOffice when I double-click it? – ændrük Jun 10 '11 at 13:35
That is a nautilus configuration, not using file output information. – enzotib Jun 10 '11 at 14:03
Because (of nautilus usage) of mimetypes: there are more than 1 images filetypes that can be openend by more than 1 program. He asked for a way in command line to identify files. screenshot.png.odf is an image from your example. screenshot.png.odf could also have shown you "Microsoft Office Document" if it was created in word ;) – Rinzwind Jun 10 '11 at 14:03
Thank you Rinzwind – wojox Jun 10 '11 at 21:11

Is this what you are looking for?

share|improve this answer

Be aware that Linux doesn't care too much about file name extensions. It determines the file type based on the file's contents/MIME type, so knowing a file extension doesn't give too much insight into a program's usage pattern.

See What is the relationship between MIME types and File .extensions? and How are file-extensions/mime-types/icons/default applications asssociated? for more info.

share|improve this answer
Linux may not care too much, whatever that means, but GNOME certainly does. Try gnome-opening a file with a misleading extension and you'll see what I mean. – ændrük Jun 10 '11 at 13:37
yeah, you're right, and I think gnome-open is messed up in that regard. – Christoph Jun 10 '11 at 14:10
@ændrük: Doesnt gnome-open follow MIME/type ? If so, file extension is only a part of the puzzle... not even the most important one – MestreLion Jun 10 '11 at 14:48

Technically, the list of known file extensions is stored in /usr/share/mime/globs. Here's a copy with nicer formatting.

I'm not sure how to decide which file extensions are "common". This list claims to be "common" but I think I've only ever run across about five percent of it.

share|improve this answer
+1 good find :) – Rinzwind Jun 10 '11 at 14:07

Your Answer


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.