$linuxjunkies
>

xdg-open(1)

Open a file or URL with the user's preferred application.

UbuntuDebianFedoraArch

Synopsis

xdg-open [OPTION]... FILE|URL

Description

xdg-open opens a file or URL in the user's preferred application based on file type or URL scheme. It follows the freedesktop.org specification, automatically detecting whether to use a web browser, document viewer, image viewer, or other handler registered in the desktop environment.

This command respects the user's MIME type associations and default applications configured in their desktop settings (GNOME, KDE, XFCE, etc.), making it the standard way to open files from scripts and command-line tools.

Common options

FlagWhat it does
--helpDisplay help message and exit
--versionDisplay version information and exit

Examples

Open a URL in the default web browser

xdg-open https://example.com

Open a PDF file with the default PDF viewer

xdg-open document.pdf

Open an image with the default image viewer (GIMP, Feh, Eye of GNOME, etc.)

xdg-open image.jpg

Open a text file with the default text editor

xdg-open /path/to/file.txt

Open the current directory in the default file manager

xdg-open .

Open the default email client with a new message to the specified address

xdg-open mailto:[email protected]

Open a Word document in the background without blocking the terminal

xdg-open report.docx &

Related commands