Almost every desktop environment has a mechanism for determining what to do when you (double)-click a file in file manager/explorer windows. This can be based on the extension, or on whatever file does, etc.

Now, suppose I have a terminal window open within a desktop session and I'm at some folder. Is there some binary or script - hopefully valid across multiple desktop environments common to Linux - which, when executed with a filename as its argument, uses this mechanism and has the same effect as (double)-clicking that file would?

If there isn't a single multi-desktop-environment way to do this - are there a bunch of desktop-environment-specific binaries/scripts with this functionality? If so, can you list such a bunch?

On Windows I think this exists in the form of the start command (although, of course, they can assume a single desktop environment.)

  • 1
    For Ubuntu see here. Maybe this works for other linux too.
    – ridgy
    Jun 9, 2017 at 11:47
  • +1 xdg-open is part of the freedesktop xdg-utils suite - so should be a bit more generic than just Ubuntu I think Jun 9, 2017 at 11:49
  • You're right, thank you. See unix.stackexchange.com/questions/251054/…
    – ridgy
    Jun 9, 2017 at 11:51
  • @steeldriver: Make that an answer so I can accept?
    – einpoklum
    Jun 9, 2017 at 13:00

1 Answer 1


For desktop environments that implement the freedesktop.org xdg-utils tools, you should be able to use xdg-open:


xdg-open — opens a file or URL in the user's preferred application Synopsis

xdg-open { file | URL }

xdg-open { --help | --manual | --version } Description

xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser. If a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.

xdg-open is for use inside a desktop session only. It is not recommended to use xdg-open as root.


--help Show command synopsis.

--manual Show this manual page.

--version Show the xdg-utils version information.

Your Answer

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

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