Mailcap
lastmod 2026-02-18created 2026-02-181 edits
mailcap is a system that defines which program handles files of each MIME type. It was originally created to specify the programs email clients use to open attachments (RFC 1524), and today various programs consult it when looking up MIME handlers.
Configuration files
| File path | Description |
| | System-wide configuration |
| | Per-user configuration (takes precedence) |
Format
Each line has the form MIME type; command to run, and the file path is substituted for %s.
Option fields
In addition to the basic format, extra options can be specified, separated by semicolons (;).
image/gif; feh %s; test=test -n "$DISPLAY"
text/html; lynx %s; needsterminal
application/pdf; evince %s; description="PDF Viewer"
| Field | Description |
| | Use the entry only when the condition is true |
| | Marks the program as requiring a terminal |
| | Produces a large amount of output, so it is displayed through a pager |
| | Description of the entry |
| | Command used to create a file of that MIME type |
| | Command used to edit a file of that MIME type |
Related commands
| Command | Description |
| | General-purpose command that opens files according to the mailcap configuration |
| | Alias for |
| | Alias for |
| | Alias for |
mailcap vs xdg-open
| Item | mailcap | xdg-open |
| Configuration method | Text file ( | |
| Main environment | CLI / headless servers | GUI desktop environments |
| Standard | RFC 1524 | freedesktop.org XDG specification |
| Pros | Simple and intuitive | Integrated with the desktop environment |