← All commands
Topic hub File Management
Windows Linux File Management Expanded guide 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

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.

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

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.

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

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.

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