How can I associate a certain file type again with "View file"
Asked Answered
C

2

13

After installing a fresh Ubuntu (13.04) pem files (SSL certificates) are associated with "View file" (right click the file in Nautilus I see "Open with View file"), which nicely shows a clear text version of the certificate.

Now I wanted to edit the file and so chose "Open with another application" and selected gedit. It worked, but now I only see "Open with gedit" and cannot revert back to the "View file" program (or add it as another option). I also noticed many applications (for example Sublime, which is available in the Unity Lense) are missing in the dialog where I can choose which application to use for opening the file.

How can I get more (all that are "known" to unity, for example the lense) applications shown in the dialog where I can associate a file type with an application? Where can I find the "View file" application?

Caught answered 4/6, 2013 at 8:53 Comment(2)
The "View file" for certificates is actually /usr/bin/gcr-viewer from gcr packages, as stated in @pim's comment here.Pourpoint
I always forget its name. Thank you! Your comment should really have more upvotes.Jeconiah
C
11

Look at the file:

~/.local/share/applications/mimeapps.list

That will contain something like (this example is for a *.crt file):

[Added Associations]
application/pkix-cert=gvim.desktop;

Remove the offending line. You don't need to restart anything for the change to take effect.

Chit answered 15/1, 2014 at 23:10 Comment(4)
Thanks for this tip - worked great. Is there any way to get both apps to show so that you can double click the file to see the certificate as per default and also right click and do "open with other application" and view it in gedit?Padnag
Please review the file: ~/.config/mimeapps.list I had to remove the offending line from that file in order to solve the problem. Regards!Dalhousie
In Ubuntu 16.04 I haven't found anything in ~/.local/share/applications/mimeapps.list. I've had to remove it from ~/.config/mimeapps.list as user5660553 said.Gazo
this is lifesaving tipApocalyptic
M
2

For Ubuntu 22.10, the filetype associations are defined in a hierarchy of files called mimeapps.list:

$ locate mimeapps.list
~/.config/mimeapps.list
~/.local/share/applications/mimeapps.list
/snap/core/14447/usr/share/applications/mimeapps.list
/snap/core/14784/usr/share/applications/mimeapps.list
/snap/core18/2679/usr/share/applications/mimeapps.list
/snap/core18/2697/usr/share/applications/mimeapps.list
/snap/core20/1778/usr/share/applications/mimeapps.list
/snap/core20/1822/usr/share/applications/mimeapps.list
/snap/core22/509/usr/share/applications/mimeapps.list
/snap/core22/522/usr/share/applications/mimeapps.list
/usr/share/gdm/greeter/applications/mimeapps.list

/snap/core22/509/usr/share/applications/mimeapps.list contains the default association for *.crt files:

[Default Applications]
x-scheme-handler/http=xdg-open.desktop
x-scheme-handler/https=xdg-open.desktop
x-scheme-handler/mailto=xdg-open.desktop
x-scheme-handler/help=xdg-open.desktop

The above associates xdg-open with CRT files.

Clicking on a crt file displayed by an Ubuntu file manager like Nautilus causes xdg-open to open the file. You can also accomplish the same thing with the command line. For example, typing the following causes aw.crt to open:

$ xdg-open aw.crt

This is what xdg-open displays:

xdg-open display

As you can see, this is a combined certificate, containing not just one certificate, but an entire certificate chain. Clicking on any of the red > Details buttons causes more information to be displayed about one of the certificates in the chain.

The above is a portion of a blog post I wrote about generating wildcard SSL certificates on Ubuntu.

Milstone answered 2/3, 2023 at 15:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.