9

I would like to know if there is a command to open any file in Linux independently of their extension, just as if you were double-clicking it.

  • this is more associated with the mime types which are registered by your window manager desktop than to an application per se. In short, afaik there is no "double click" equivalent in command line as the double click is in fact a combination of a file picker + a list if registered mime types. – vfbsilva Jul 19 '15 at 0:01
  • 9
    xdg-open THE_FILE – PSkocik Jul 19 '15 at 0:06
  • 2
    Related: (if you don't have xdg-open) How does xdg-open do its work – Mark Plotnick Jul 19 '15 at 0:34
5

There are commands that are similar to the double-click: see and open. They may not be on every distro, but they are there on my Ubuntu 12.04 server.

It would be good to point out that extensions are actually kind of arbitrary. There are so many esoteric extensions out there; no program, including the "double-click" can possibly know how to interpret every file out there.

And if you know the contents of file and the right program to run it, you should be able to execute/use the file regardless of its extension.

xdg-open is another one, though I think it is typically distributed with GUI distributions, as I don't see it in my AWS Ubuntu instance, nor my development Ubuntu server.

  • 6
    xdg-open is much more standard than what you suggest. – Basile Starynkevitch Jul 19 '15 at 2:45
  • 1
    see and open are specific to Debian and derivatives. xdg-open is pretty much de facto standard nowadays (it's a Freedesktop standard). – Gilles Jul 19 '15 at 21:25
1
gnome-open "filename"

works like a charm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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