← All commands
Topic hub File Management
Windows Linux File Management File System

Windows assoc / ftype (file extension to program) equivalent in Linux

Views or changes which application opens files of a particular type.

Windows assoc / ftype (file extension to program)
Linux equivalents
Debian/Ubuntu same command
xdg-mime
Fedora same command
xdg-mime
Arch same command
xdg-mime

Overview

What this command does

Views or changes which application opens files of a particular type.

Migration tip: On desktop Linux, file associations are managed through xdg-mime. Most users prefer to change them through the file manager GUI (right-click → Open With → Set as Default).

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 optionUse
xdg-mime query default application/pdfSee what opens PDFs
xdg-mime default okular.desktop application/pdfSet default PDF viewer
file myfileDetect actual file type from content
xdg-open file.pdfOpen file with its default app

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference 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

Related File Management commands