To the best of my knowledge, all shortcuts in the Unity Launcher have a corresponding *.desktop file. I have one shortcut (for skrooge) that doesn't have an icon. How can I find the *.desktop file corresponding to this shortcut so that I can add an icon to it?
9 Answers
It's probably sitting in /usr/share/applications/
but if you want to find every .desktop
file on the system run this:
find / -name '*.desktop'
or
sudo updatedb
locate *.desktop
To find files with "skrooge" in their path or name, add a grep to the command:
locate *.desktop | grep -iR "skrooge"
The system stores the .desktop files in /usr/share/applications/
. Unfortunately, if you open that folder in nautilus the .desktop files appears with the icon specified in the file and with the file name called out within the file. You also won't be allowed to edit these files by clicking on them and selecting edit.
To edit these files, you need to open that folder within a terminal window. Doing an ls
command will show all the .desktop files with their actual names. When you locate the .desktop you wish to change, run gksudo gedit {file-name}.desktop
.
It's normal practice to keep any .desktop files you create or edit in your home folder ~/.local/share/applications
.
-
1Running from the terminal can be handier for some, but it is also possible to drag from nautilus into gedit or another text editor. – Jon Hanna May 01 '14 at 21:40
-
what's the point of the directory "~/.local/share/applications"? Files there don't seem to be used, not I cannot add them as "shortcut" to Unity. – Malachiasz Feb 08 '15 at 15:14
-
4@Malachiasz Actually, the *.desktop files from
~/.local/share/applications
are reloaded when session restarts. So, log out and log back in. Note that these are specific to that user. – akshay2000 Mar 21 '15 at 07:11 -
1I also found this Q&A here on site useful: How to force Unity reload ~/.local/share/applications/ – hakre Sep 18 '17 at 18:19
-
Does copying a desktop file from
/usr/share/applications
override the entry in~/.local/share/applications
? I'm trying to configure Firefox to usefirejail
, but whenever the browser updates my edits are removed if I do it in the desktop file from/usr/share/applications/
. – Daniel Oct 19 '20 at 04:52 -
Don't forget that snap applications store their
.desktop
files in/var/lib/snapd/desktop/applications/
– Flimm Jan 20 '22 at 07:26
Some additional details to supplement the other answers:
Typically, .desktop
files for packages will be located in /usr/share/applications
.
If you want, you could copy one to ~/.local/share/applications
and edit it there without needing sudo. Items in ~/.local/share/applications
will override matching items in /usr/share/applications
and /usr/local/share/applications
, but are only visible to your user.
Alternatively, you could place an edited copy in /usr/local/share/applications
where it will override any in /usr/share/applications
while also being visible to the entire system.
Note that you should not edit the .desktop
files in /usr/share/applications
directly; any changes you make will be automatically overwritten when the application is updated by the package manager.
Extracted from here

- 19,615
- 55
- 79
- 83

- 961
- 3
- 12
- 22
-
1
-
1Don't forget that snap applications store their
.desktop
files in/var/lib/snapd/desktop/applications/
– Flimm Jan 20 '22 at 07:27
You can find all directories with desktop files in the XDG_DATA_DIRS
environment variable. The *.desktop
files can be in the applications
directory in each of the directory in that variable. E.g.:
> echo $XDG_DATA_DIRS
/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
You can use this bash script to list all desktop files used by the system (e.g. to build the panel or applications menu):
for p in ${XDG_DATA_DIRS//:/ }; do
find $p/applications -name '*.desktop'
done
It seems that desktop files can also be placed in one more directory, which isn't in the XDG_DATA_DIRS
variable:
~/.local/share/applications
So, the complete script to find all *.desktop
files in the system is:
DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share"
for p in ${DATA_DIRS//:/ }; do
find $p/applications -name '*.desktop'
done
I didn't find any documentation for this but there's some information about this environment variable here: https://unix.stackexchange.com/a/531664

- 229

- 675
-
4
-
2This is missing
~/.local/share/applications
and~/var/lib/snapd/desktop/applications
isn't it? – lrkwz Oct 28 '21 at 11:13 -
1
-
1Freedesktop.org (formerly the X Desktop Group) maintains the XDG Base Directory Specification which includes the XDG_DATA_DIRS environment variable. The spec is used beyond the Unity Launcher; Google's ChromeOS Crostini and Microsoft's WSLg also use it to integrate GNU/Linux programs into their respective UIs. – M.W. Nov 18 '21 at 21:55
-
@lrkwz I found
/home/USERNAME/.local/share/applications
and/var/lib/snapd/desktop/applications
in myXDG_DATA_DIRS
environment variable. – Flimm Jan 20 '22 at 07:29 -
I think that the value of the XDG_DATA_DIRS variable depends on the version of the system. On my system (Ubuntu Focal 20.04) it contains /var/lib/snapd/desktop but it doesn't contain ~/.local/share. On the other hand, the desktop files in my ~/.local/share/applications aren't displayed in the system menu, so I think that this location isn't supported in my system by default. It's possible that it's supported on a newer version of Ubuntu. – OndroMih Jan 21 '22 at 15:24
Desktop files of snap packages can be found in /var/lib/snapd/desktop/applications/
and below /snap/
.

- 1,526
-
In what order are they looked up, relative to
~/.local/share/applications
and$XDG_DATA_DIRS
? – wjandrea Nov 01 '21 at 21:55
I know I'm late to the party, but I have a faster solution than the one accepted as the answer:
find / -iname "*desktop" -type f -not -path "/media*" -exec grep -il skrooge '{}' ';' 2> /dev/null
It's faster because it doesn't search the data mounted file systems and most probably the desktop file is located in the system partition.
Moreover, it's more likely to find what the command from the accepted answer would miss. That's because the desktop files doesn't have to hold the application name. This command actually searches the text in every desktop file.

- 423
- 5
- 8
-
This did not work for me at all (not even with sudo). I am using Manjaro linux though, but the command should work independent of the OS as long as it has
find
,grep
. It results in a crash of the command printing nothing. – Rahat Zaman Jun 09 '20 at 01:31 -
-
there is no output. After 2-3 minutes, it just returns back to the shell prompt. – Rahat Zaman Jun 12 '20 at 07:28
-
You mentioned crash in your first comment. What do you mean by it? Also, where do drives get mounted in Manjaro? Did you update skrooge to the application you're looking for? – joker Jun 16 '20 at 12:21
/usr/share/applications
(most applications, admin rights)~/.local/share/applications
(personal ones)

- 1,575
- 2
- 17
- 26
-
2These answers have already been provided in the two top voted answers in much more detail. – Kevin Bowen Apr 09 '22 at 02:20
Commandline output for all .desktop files in your system.
sudo find / -type f -name "*.desktop" -exec echo $PATH {} \;
This one will dump the terminal spew out to a text file on your desktop so you can actually read it.
sudo find / -type f -name "*.desktop" -exec echo $PATH {} \; 1>~/Desktop/Desktop-files-output.txt
once found, if its not in /usr/share/applications
you can do sudo ln -s [the .desktop name] /usr/share/applications/[the .desktop name]
which will add a link to that directory and make it appear in your applications menu.
if it is in there; change or add these lines to the .desktop file;
NoDisplay=false
Hidden=false
If it doesn't have a .desktop, you can make one;
cat>>Skrooge.desktop<<EOL
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=name
Comment=[what it does]
Path=/working/directory/comment/this/out/if/you/are/going/to/use/$HOME
Exec=[the command line command you use to launch it.]
Icon=/usr/share/icons/icon.png
Type=Application
NoDisplay=false
Hidden=false
Categories=menucategory1;category2
Terminal=false[unless its a commandline only program like htop]
EOL
Then run chmod +x Skrooge.desktop
Once made and proven to work, drop it in /usr/share/applications
so it shows up in your applications menu.
-
-
Yes @muru, I've ran that find command before. it outputs all non-errors to a file on the desktop. It requires root to work properly. its about as harmful as a
sudo ls
command. – some Cat you don't know Mar 21 '24 at 15:21 -
I do not actually now which .desktop file becomes effective. My best guess is, from https://wiki.archlinux.org/index.php/Desktop_entries , to make a script like this and run it:
#!/bin/sh
# try to find the effective desktop file
# (there seems to be no documented standard for this)
use_if_desktop_file () {
if [ -r "$1" ] &&
[ "$(xdg-mime query filetype "$1")" = application/x-desktop ]; then
echo "$1"
exit
fi
}
for d in ~/.local/share/applications /usr/local/share/applications \
/usr/share/applications; do
use_if_desktop_file "$d/$1"
use_if_desktop_file "$d/$1.desktop"
done
# no file found
exit 1

- 117,780
locate -i "*skrooge*.desktop"
. Though there's mainly three places unity will look for desktop files.~/.local/share/applications
,/usr/local/share/applications
and/usr/share/applications
. If there are desktop files for the same command in multiple places, it'll use the left-most of the three I listed. – geirha Mar 30 '12 at 14:32/usr/share/applications/kde4/skrooge.desktop
. Thanks. :) – KOVIKO Mar 30 '12 at 15:08locate *.desktop
helped me discover that desktop files fromsnap
package installs seem to go into the/snap/
and/var/lib/snapd/desktop/applications/
directories. – Gabriel Staples Aug 10 '20 at 02:05locate *.desktop
doesn't find anything.find / -name '*.desktop' 2> /dev/null
to suppress the 'permission denied' flood. – Mark Jeronimus Oct 30 '20 at 09:48~/.local/share/applications
is where you put your desktop files so that in Activities window can find it and add it to Favorite (anchor it on deck). – WesternGun May 18 '21 at 07:22