How do I mark a .desktop file as trusted in Ubuntu 18.04?

None of the answers provided up to this point have included information about how you can do this in a non-interactive manner. What if I want to script the creation of a launcher and make it trusted without having to click on it?

This usage case is already addressed in this question with this answer. I'm duplicating this information here because this question was much easier to find, and it is not strictly a duplicate because the question here is larger in scope.

To set a launcher as trusted from the command line, run:

gio set /path/to/your/launcher.desktop "metadata::trusted" yes

With that done, press F5 on the desktop or in the current folder to refresh the view. The launcher should now be trusted.

There are certain conditions that must be met (ownership, running programs, running gio as the correct user). See Sander's answer for the full list.


  • First set the executable bit of the .desktop file like you did already. You may also do this by right-clicking the file in the file manager and setting the executable property on the "Permissions" tab of the "Properties" dialog if you find that easier than the command line.
  • Now try launching the icon again by double-clicking it. Again, a dialog appears, but note: it is a different dialog. This time, select the "Launch and trust" button, and your desktop file will now turn into a functional launcher with the right icon.

after hours of searching, I finally found what was causing my problem with the .desktop files never being trusted and not showing icons:

Change the owner to your user name (mine was set to root which was breaking things):

sudo chown $USER:$USER ~/.local/share/gvfs-metadata/home*

credit to @George Udosen who helped me fix it: GVFS-WARNING **: can't init metadata tree /home/user/.local/share/gvfs-metadata/home: open: Permission denied


Set the proper user name and group name for the particular desktop file (chown) . Now try to launch again, dialog appears select the "Launch and trust" button.