3

How can I find out the default applications on Linux - CentOS/Ubuntu - using the command line?

I tried to use xdg-mime and read the environment variables using printenv, but no result. I just need a command to tell me:

  • This is the default browser
  • This is the default mail client
  • This is the default office suite
  • This is the default antivirus
  • This is the default firewall
  • This is the default antispyware
1
  • 1
    Why? If you need to open a file with its default program, run xdg-open. Feb 12, 2018 at 15:00

1 Answer 1

11

You should find what you are looking for in /usr/share/applications/defaults.list and/or ~/.local/share/applications/mimeinfo.cache.

For example, I have:

-> cat /usr/share/applications/defaults.list | grep mailto
x-scheme-handler/mailto=thunderbird.desktop
-> cat /usr/share/applications/defaults.list | grep http  
x-scheme-handler/http=firefox.desktop;google-chrome.desktop
x-scheme-handler/https=firefox.desktop;google-chrome.desktop

Note that what is defined in the mime files of your home directory have priority over the ones in /usr/share/applications.

You can also use xdg-mime:

-> xdg-mime query default text/x-c               
emacs24.desktop
-> xdg-mime query default x-scheme-handler/http 
exo-web-browser.desktop

If you also have exo-something.desktop (xfce), you can check what it is with exo-preferred-applications.

4
  • 1
    It works on Ubuntu but don't work on CentOS: No such file or directory.
    – Neagu V
    Apr 14, 2016 at 16:00
  • 2
    @NeaguV For both of them? Maybe you have a /usr/share/applications/mimeinfo.cache? Apr 14, 2016 at 16:03
  • It is not ok becouse it returns: x-scheme-handler/http=firefox.desktop;google-chrome.desktop --- and i dont know witch one is the default one !!
    – Neagu V
    Apr 15, 2016 at 7:30
  • @NeaguV I believe it's the first one (if installed). You can check by running xdg-open http://stackexchange.com/. I edited my answer, you can use xdg-mime to get the default application without alternatives. Apr 15, 2016 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.