Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
1  
In little related I found this little gem to open Finder in a certain path (not current path necessarily): open -a Finder . or open -a Finder /your/path/here –  Mikko Ohtamaa Feb 10 '12 at 19:56

4 Answers 4

up vote 25 down vote accepted

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.

share|improve this answer
1  
That BASH script is a great idea. –  jweede Sep 10 '09 at 13:00
9  
cygwin: try "cygstart" –  Doug Harris Sep 10 '09 at 15:02
12  
gnome-open is GNOME-specific. xdg-open is available on all Freedesktop.org compliant distros. –  Avdi Oct 25 '09 at 14:18
    
@DougHarris, +1. cygstart may be further preferable, as in Emacs bookmarks, it allows one to continue using Emacs. With start, my Emacs is frozen. –  Brady Trainor Mar 23 at 23:17
    
Then, start is nice if you don't want to rely on Cygwin being available. start "" or "start \"\"" just worked for me. (Set of quotes "" prevents Emacs hanging on process.) –  Brady Trainor Mar 24 at 0:24
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).

share|improve this answer
3  
also works. What's the difference between xdg-open and gnome-open ? –  jweede Sep 10 '09 at 13:28
4  
well, xdg-open was developed by the freedesktop.org folks which claim to create the "standard", while gnome-open was developed by the gnome folks .. which you only get when you install gnome. i personally like the freedesktop.org stuff more. –  akira Sep 10 '09 at 13:32
2  
Indeed, xdg-open is the right answer here. gnome-open is specific to desktops that have GNOME installed. xdg-open will be available on any freedesktop-compliant system. –  Avdi Oct 25 '09 at 14:19
2  
"xdg-open will be available on any freedesktop-compliant system" means, in practice, that no matter whether you are using GNOME, KDE, Xfce, or any other environment, xdg-open will do the Right Thing, using the file-type-to-program mapping of the running environment. –  RavuAlHemio Jan 16 '12 at 20:26

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.

share|improve this answer
    
very cool. Thanks Kim! –  jweede Sep 10 '09 at 13:15
2  
Useful script, but you'll want to replace $* with "$@" (including the quotes) to properly handle filenames with spaces. –  pimlottc Jan 3 '12 at 22:44

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.