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 (may be a file or an URL) in any freedesktop compatible environment with the application registered for xyz.bar's type. See also the documentation here (man page of xdg-open).

In practive 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.