Linux equivalent for "start" and "open" on the command line

8

The Windows command line uses start programname and start filename.ext to process the file as if the user had double-clicked it in the GUI shells we all know and love. MacOS's command line does the same with open. That is useful for those of us who don't know the exact program and location for opening unusual file types.

On Linux, ./filename.ext is to run scripts, and start filename.ext responds with an error because it's expecting a "job". So...

What is the standard CLI command to open a non-script file under whatever the registered type-handler under Linux? If it's not standard, what does Red Hat use?

Vlueboy

Posted 2011-06-12T00:45:10.243

Reputation: 673

Question was closed 2014-07-28T14:13:43.797

./filename.ext isn't only for scripts but for any executable file. – Andrew Lambert – 2011-06-12T02:29:48.260

Answers

8

The freedesktop.org standard uses xdg-open. There are others specific to KDE, GNOME, and other desktops, but xdg-open should work regardless.

geekosaur

Posted 2011-06-12T00:45:10.243

Reputation: 10 195

+1. That was fast! I made a quick edit like a second after posting and saw your reply. And it works. I didn't think each desktop environment bundled their own as well. Thanks! – Vlueboy – 2011-06-12T00:49:55.683

xdg-open does not always work good (and compatible with desktop environment). For a gnome user, gnome-open is probably better. – saeedgnu – 2011-06-12T08:00:23.220

@ilius: xdg-open is just a shell script, and is supposed to call gnome-open if it detects that you are running GNOME. ("Patches welcome.") – user1686 – 2011-06-12T08:52:55.147

I was thinking that a terminal emulator (like gnome-terminal or konsole) can do this in a smart way, for example when you write a path as command, check for mime-type of that file, and if mime-type was not in a configurable list of mime-types, just run that file with xdg-open, instead of executing the file itself. – saeedgnu – 2011-06-12T09:41:49.163

@ilius: Terminal emulators don't do that. They just start a shell (usually bash), give your input to it, and display output to screen. A shell could do it, but I guess it would introduce security holes or something. – user1686 – 2011-06-12T10:38:57.993

@grawity hmmm yes – saeedgnu – 2011-06-12T10:52:37.350

1

@grawity: no reason the shell couldn't, and in fact recent versions of zsh can be configured to recognize file types and run the appropriate program. It's just not part of Unix-think.

– geekosaur – 2011-06-12T14:50:16.417