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

I am asking this out of curiosity, to know what goes on 'behind the scenes' when I double click a file in a file browser, say Nautilus. Specifically, what parameters is the executable executed with? Where does the .desktop file come into play, and how does Nautilus send the filename?

This was relevant to me once when Okular would open multiple instances of the same file, and I had to write a shell script, which used to fail because the filename didn't get passed properly. (Spaces in the filenames would get converted into an HTML %20 character, and I had to figure out a lot how exactly filenames are passed.)

share|improve this question
up vote 1 down vote accepted

There are two directories that contain .desctop files: /usr/share/applications/ (global list for all users) and ~/.local/share/applications/ (for a particular user). Both directories contain a list of file type associations (defaults.list and mimeapps.list correspondingly).

When you click a file, Nautilus finds the appropriate .desctop file and launches your program. Each .desctop file contains the Exec key which specifies the command line (the program and its parameters). See this document for details on the Exec key.

If a .desctop file specifies a program without the full path, it will be looked up on your $PATH. In a default installation, $PATH usually includes the following directories: /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin.

share|improve this answer
Thanks! And what happens if both .desktop files are removed? Will it ask me to select which program to open it with? – Abhinav Jan 21 '14 at 6:43
I have just created a binary file with no content type specified in it, and with a random extension (.ttt). I tried to open it in Nautilus. I got a The file is of an unknown type message, and there was a button for selecting one of the registered programs there. I think, if you remove any associations for a particular content type, something similar will happen :) – Alexey Jan 21 '14 at 8:06

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.