For example, I found Firefox's process command line: /usr/lib/firefox/firefox. I browse to this location and double-click it, it prompts this:
However, if I type the command in terminal, it works normally.
Simple reason is that file manager recognizes the file type. If you double-click /usr/share/applications/firefox.desktop
or any other .desktop
file for that matter, the file manager will execute it as application. Otherwise, file manager looks up which filetype corresponds to which application.
And that's were /usr/lib/firefox/firefox
comes in. It is compiled as shared object.
$ file /usr/lib/firefox/firefox
/usr/lib/firefox/firefox: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=d2a4bfe9dbe1aadd5480a6b5612b7a3fc1fd01a2, stripped
This type of file has been touched on in detail in kos's answer, but basically shared object is an executable file, which can be used as library. Libraries usually are included into other software, hence Nautilus can ignore and has no default program assigned to it. By contrast, to shell (or rather kernel, to which execve()
call will pass the path to that file) recognizes that as executable file just fine.
Now, what gets executed when you execute firefox.desktop
? That's /usr/bin/firefox.sh
- a wrapper script which does a few checks and replaces itself with /usr/lib/firefox/firefox
later on. In this case, shell script is detected as filetype and Nautilus happily spawns that. There's a lot of other things that happen behind the scenes, but that's the general gist of it all.