How can I remove orphaned start menu entries?

For some reason I have a bunch of left-over start menu entries from applications (e.g, Gnome Do, Synapse, Leafpad.) and was wondering if there’s a way to remove all orphaned entries for applications that are no longer installed?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

You can use the following command to list application icons that link to nonexistent programs:

for i in {/usr,~/.local}/share/applications/*.desktop; do which $(grep -Poh '(?<=Exec=).*?( |$)' $i) > /dev/null || echo $i; done

I suspect you’ll find that most of yours are customized icons in your home folder, since these are not automatically cleaned up by the package manager. If this is the case and you’d like to trash Install trash-cli them all at once, you can use a modification of the previous command:

for i in ~/.local/share/applications/*.desktop; do which $(grep -Poh '(?<=Exec=).*?( |$)' $i) > /dev/null || trash $i; done

Or, of course, browse to ~/.local/share/applications/ in Nautilus and trash them via the graphical interface.

Solution 2

If by start menu you mean the ‘Applications’ menu, you can edit it by going to:
System -> Preferences -> Main Menu.

You can add, rearrange, edit and delete entries at will.

Solution 3

When an application is uninstalled it should remove menu items it installed. And it work this way on my machine.

If it works differently, it is a bug of a particular package or a problem on your system. I cannot believe that you have more than 40 entry orphaned. It would be the symptom of a problem.

Solution 4


Following @ændrük answer, here is a similar solution that support spaces in path and subfolders, this can be used on a specific folder or the the entire disk to look for broken .desktop files (shortcut)

find {/usr,~/.local,/usr/local,}/share/applications/ -name '*.desktop' | while read -r line; do which $(grep -Poh '(?<=Exec=).*?( |$)' $line) > /dev/null || echo $line;  done

For the entire disk

find / -name '*.desktop' | while read -r line; do which $(grep -Poh '(?<=Exec=).*?( |$)' $line) > /dev/null || echo $line;  done

Note: that any method can show false positive check twice found files before deleting them

Solution 5

Well, this one is hard but i want, at least, to tell you what’s the problem.

Gnome stores the installed applications in /usr/share/applications with files ended in .desktop (so vlc program is launchad by vlc.desktop)

Inside each one, there’s a “Category” section in which you can set in what part of the Applications menu that program you want it to be. The thing is: the only way i think it can be done what you are asking for is using a bash script that ask if the package related to that .desktop is installed or not. if it’s not, delete that .desktop file. When you delete the file, it will be out of the menu, and when you app is in a category, that one isn’t shown.

That one is a bit out of my scope because every command (dpkg, apt-get, etc..) always return a good exit when they say the package isn’t installed, so we have to read the exit from that app searching for a String (f.i. “not installed”), check it, and if the String exists, it means the application isn’t installed and the .desktop can be deleted.

So, if you want, you could just enter the folder (/usr/share/applications) and click on files that correspond to the programs. They’ll dissappear from the Applications menu. To do it automatically, i guess we need a good bash script on the track i said.

I hope this helps in some way.

Solution 6

I found on the internet a very smart person who knew of a program called Alacarte (easy GNOME menu editing) program. It installed using the software manager. It’s so easy to use. Just click on to highlight the uninstalled program entry you want to get rid of and click delete on the right and it’s done.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply