Shell – How to find out which program can open a given file

command linefile openingfilesshell

Let's say I have a file thesis.pdf or picture.jpg

Is there a command which returns a program to open this file with?

I am aware of the command file, but it just returns the correct type of the file (I know that this is not specified by its extension in Linux) and not a program.

I am expecting something like:

$ program 'picture.jpg' 
gimp, gwenview, eog

Best Answer

mimeopen -a 'picture.jpg'

This is what you need

It will give you output like this

Please choose an application

    1) Shotwell Viewer  (shotwell-viewer)
    2) Firefox Web Browser  (firefox)
    3) Image Viewer  (eog)
Related Question