M HYPE SPLASH
// general

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

By Emma Terry

Coming from Mac OS X, you can type:

$ open yourfilehere.txt

and your file will open just as if you had opened it from Finder.


On Windows, one can type:
> start yourfilehere.txt

and it will open just as if you had opened it from Explorer.


On Ubuntu, I'd like to be able to open files in the same manner in GNOME. What's the command? 2

5 Answers

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.

7
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).

5

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.

1

You can use the gnome-open command in your Terminal. Once in the directory which you want to open an OS window of, type in the Terminal:

gnome-open .

This will open a window showing what is in this folder. Similarly, you can specify a subfolder located in this directory by substituting the . by the name of the subfolder.

Note that if gnome-open doesn't work, it may just need to be installed. You can do so using Synaptic (sudo apt-get update and thensudo apt-get install synaptic in your terminal, very convinient when installing package because it installs all the dependencies properly) or directly install Gnome Shell in your Terminal: sudo apt-get install gnome-shell

Enter this into the terminal: ./yourfile

yourfile is the name of the file you want to open or run. You can also use this command to run bash scripts. (Remember to enter the file extension!)

gnome-open is what you're looking for.

Another quote from another poster.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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