Linux equivalent of the Mac OS X "open" command

Liu Chang picture Liu Chang · Nov 5, 2008 · Viewed 70.8k times · Source

I've found the "open" command in Mac OS X very handy in the command line. From "man open":

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.

That is, if I want to open a PDF file with the default PDF viewer (happens to be Preview), I only need to do:

open my.pdf

In Linux, however, to open a PDF file from the command line, I had to dig around to find the default PDF viewer is, for instance, "evince" (who'd have guessed??), and then

evince my.pdf

So, is there a simple equivalent of the 'open' command in the Linux command line?

Thanks!

Answer

number5 picture number5 · Nov 5, 2008

You could try xdg-open, most Linux distros have it. It will open default associated app for your file.

FYI https://portland.freedesktop.org/doc/xdg-open.html