Linux equivalent command for "open" command on Mac/Windows?
Coming from Mac OS X, you can type:
$ open yourfilehere.txtand your file will open just as if you had opened it from Finder.
On Windows, one can type:
> start yourfilehere.txtand 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" ;;
esacGood 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.barwill 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"
donePut this into a shell script named open and
open *.cwill open all c files in the current directory.
1You 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-openis what you're looking for.
Another quote from another poster.