XDG-OPEN(1)

โœจ NAME โœจ

xdg-open โ€” opens a file or URL in the user's preferred application ๐Ÿ’…

okay bestie, so this is the lil man page for xdg-open, from the xdg-utils manual, and it's honestly iconic for one specific reason: it's the vibe-check of "just open this thing the way I like it" ๐Ÿซถ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

xdg-open {file | URL}

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

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

xdg-open opens a file or URL in the user's preferred application. That's literally the whole thing and it ate. ๐Ÿ”ฅ

Hand it a URL? Boom, it opens in your preferred web browser. Hand it a file? It opens in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.

โœจ Important vibe check: xdg-open is for use inside a desktop session only. And it is not recommended to use xdg-open as root. Like, please don't, bestie ๐Ÿ˜ญ

So here's the lil gotcha: xdg-open can not handle arguments that begin with a -, so if you're passing filepaths you should do it one of these ways:

  • Pass absolute paths, i.e. by using realpath as a preprocessor.
  • Prefix known relative filepaths with a ./. For example using sed -E 's|^[^/]|./\0|'.
  • Pass a file URL.

๐Ÿ’… OPTIONS ๐Ÿ’…

  • --help โ€” Show command synopsis. (the quick lil "what do I type" moment ๐ŸŽ€)
  • --manual โ€” Show this manual page. (you're soaking in it rn ๐Ÿ’–)
  • --version โ€” Show the xdg-utils version information. (so you can flex which version you're on โญ)

๐Ÿ‘‘ EXIT CODES ๐Ÿ‘‘

An exit code of 0 indicates success while a non-zero exit code indicates failure. The following failure codes can be returned:

  • 1 โ€” Error in command line syntax.
  • 2 โ€” One of the files passed on the command line did not exist.
  • 3 โ€” A required tool could not be found.
  • 4 โ€” The action failed.

Okay now the tea on success โ˜• In case of success the process launched from the .desktop file will not be forked off and therefore may result in xdg-open running for a very long time. This behaviour intentionally differs from most desktop specific openers to allow terminal based applications to run using the same terminal xdg-open was called from. That's not a bug babes, that's on purpose ๐Ÿ’€โœจ


๐ŸŒˆ REPORTING ISSUES ๐ŸŒˆ

Please keep in mind xdg-open inherits most of the flaws of its configuration and the underlying opener. (it's giving "not my fault, it's my environment" ๐Ÿ™ˆ)

In case the command

xdg-mime query default "$(xdg-mime query filetype path/to/troublesome_file)"

names the program responsible for any unexpected behaviour you can fix that by setting a different handler. (If the program is broken let the developers know ๐Ÿ‘€)

Also see the security note on xdg-mime(1) for the default subcommand.

If a flaw is reproducible using the desktop specific opener (and isn't a configuration issue): Please report to whoever is responsible for that first (reporting to xdg-utils is better than not reporting at all, but since the xdg-utils are maintained in very little spare time a fix will take much longer ๐Ÿ˜ญ)

In case an issue specific to xdg-open please report it to https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues . ๐Ÿซถ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ


๐Ÿ“ EXAMPLES ๐Ÿ“

xdg-open 'http://www.freedesktop.org/'

Opens the freedesktop.org website in the user's default browser. ๐ŸŒโœจ

xdg-open /tmp/foobar.png

Opens the PNG image file /tmp/foobar.png in the user's default image viewing application. ๐Ÿ–ผ๏ธ๐Ÿ’–


๐Ÿ’œ AUTHORS ๐Ÿ’œ

  • Kevin Krammer โ€” Author.
  • Jeremy White โ€” Author.

legendary behaviour tbh ๐Ÿ‘‘


Copyright ยฉ 2006


โญ NOTES โญ

  1. MIME applications associations specification http://www.freedesktop.org/wiki/Specifications/mime-apps-spec/

and that's the whole thing bestie, slay ๐Ÿ’…โœจ this was xdg-utils 1.0, dated 12/06/2025, and yeah the manual page is literally called XDG-OPEN(1) โ€” iconic, no cap ๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from