Linux equivalent command for "open" command on Mac/Windows?

xdg-open is what you're looking for.

You might like this snippet I put in my .bashrc files so that whether I'm using cygwin on Windows, Linux, or OSX, I can use either the start or the open commands and they work great:

case "$OSTYPE" in
   cygwin*)
      alias open="cmd /c start"
      ;;
   linux*)
      alias start="xdg-open"
      alias open="xdg-open"
      ;;
   darwin*)
      alias start="open"
      ;;
esac

Good comments, xdg-open is indeed a better option than gnome-open as explained below. I updated my personal scripts a while ago, but forgot to update this answer.

WARNING: This will override the functionality of both openvt (virtual terminal) and start from init.


xdg-open xyz.bar

will open xyz.bar (a file or URL) in any freedesktop-compatible environment via the application registered for xyz.bar's type. See also the man page for xdg-open.

In practice this should then call kde-open, gnome-open, exo-open or possibly even open, depending on the current desktop environment (KDE, Gnome, XFCE, OS X).


You can even write a small wrapper around gnome-open to open multiple files with one command:

for i in $*
do
    gnome-open "$i"
done

Put this into a shell script named open and

open *.c

will open all c files in the current directory.