The Windows command line uses start programname and start filename.ext to process the file as if the user had double-clicked it in the GUI shells we all know and love. MacOS's command line does the same with open. That is useful for those of us who don't know the exact program and location for opening unusual file types.

On Linux, ./filename.ext is to run scripts, and start filename.ext responds with an error because it's expecting a "job". So...

What is the standard CLI command to open a non-script file under whatever the registered type-handler under Linux? If it's not standard, what does Red Hat use?

  • ./filename.ext isn't only for scripts but for any executable file. Jun 12 '11 at 2:29

The freedesktop.org standard uses xdg-open. There are others specific to KDE, GNOME, and other desktops, but xdg-open should work regardless.

  • +1. That was fast! I made a quick edit like a second after posting and saw your reply. And it works. I didn't think each desktop environment bundled their own as well. Thanks!
    – Vlueboy
    Jun 12 '11 at 0:49
  • xdg-open does not always work good (and compatible with desktop environment). For a gnome user, gnome-open is probably better.
    – saeedgnu
    Jun 12 '11 at 8:00
  • @ilius: xdg-open is just a shell script, and is supposed to call gnome-open if it detects that you are running GNOME. ("Patches welcome.")
    – user1686
    Jun 12 '11 at 8:52
  • I was thinking that a terminal emulator (like gnome-terminal or konsole) can do this in a smart way, for example when you write a path as command, check for mime-type of that file, and if mime-type was not in a configurable list of mime-types, just run that file with xdg-open, instead of executing the file itself.
    – saeedgnu
    Jun 12 '11 at 9:41
  • 1
    @grawity: no reason the shell couldn't, and in fact recent versions of zsh can be configured to recognize file types and run the appropriate program. It's just not part of Unix-think.
    – geekosaur
    Jun 12 '11 at 14:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.