Windows assoc / ftype (file extension to program) equivalent in Linux
Views or changes which application opens files of a particular type.
assoc / ftype (file extension to program)
xdg-mime
xdg-mime
xdg-mime
Overview
What this command does
On Windows, "assoc / ftype (file extension to program)" is used to manage file type associations. On Linux, the closest practical mapping shown here is "xdg-mime". Views or changes which application opens files of a particular type. This reference is grouped under File Management → File System.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows assoc / ftype (file extension to program) maps to xdg-mime for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux filesystem for Windows users.
Practical tasks
Common use cases
Manage file type associations
Views or changes which application opens files of a particular type.
xdg-mime query default application/pdf
See what opens PDFs
xdg-mime default okular.desktop application/pdf
Set default PDF viewer
file myfile
Detect actual file type from content
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
xdg-mime query default application/pdf
xdg-mime default okular.desktop application/pdf
file unknownfile
Walkthrough
Examples with explanations
# Windows: assoc .pdf or ftype pdffile
xdg-mime query default application/pdf
evince.desktop
# Change default PDF viewer to Okular:
xdg-mime default okular.desktop application/pdf
# What type is this file?
file unknownfile # ELF 64-bit / ASCII text / JPEG etc.
Reference
Common options and variations
| Command or option | Use |
|---|---|
xdg-mime query default application/pdf | See what opens PDFs |
xdg-mime default okular.desktop application/pdf | Set default PDF viewer |
file myfile | Detect actual file type from content |
xdg-open file.pdf | Open file with its default app |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
Debian/Ubuntu, Fedora and Arch all use "xdg-mime" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | xdg-mime |
Same command on this distribution. |
| Fedora | same command | xdg-mime |
Same command on this distribution. |
| Arch | same command | xdg-mime |
Same command on this distribution. |
Keep learning