xdg-open
Quick Reference
Command Name:
xdg-open
Category:
desktop utilities
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
Syntax
xdg-open {file|URL}Options
xdg-open is a simple command with very few options:
| Option | Description |
|---|---|
--help |
Display help information and exit |
--manual |
Display manual page and exit |
--version |
Display version information and exit |
File Types and Associated Applications
xdg-open uses the following rules to determine which application to use:
| File Type | Typical Application |
|---|---|
| URL (http, https, ftp) | Default web browser |
| Directory | File manager |
| Text file (.txt, .md, etc.) | Text editor |
| Image file (.jpg, .png, etc.) | Image viewer |
| Document (.pdf, .doc, etc.) | Document viewer or office suite |
| Audio file (.mp3, .wav, etc.) | Audio player |
| Video file (.mp4, .avi, etc.) | Video player |
Examples
How to Use These Examples
The examples below show common ways to use the xdg-open command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
xdg-open document.pdf
xdg-open /home/user/Documents
xdg-open https://www.example.com
Advanced Examples:
# Open a file from a script #!/bin/bash xdg-open "$1"xdg-open image.jpg
xdg-open notes.txt