Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 13 down vote accepted

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.

share|improve this answer
That did the trick! Is there anyway I can turn that into a shortcut that I can run when such a thing happens again? – Alan May 21 '11 at 18:13

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.

share|improve this answer
Hi Eugenio. That's correct, but I have to go through each one, confirm if it really is orphaned or not, and then delete it. I'm looking for a way that would do all of this for me, as I have about 40+ entries that I want to remove. – Alan May 7 '11 at 2:58
Probably the most noob-friendly answer. +1 – tir38 Dec 27 '13 at 7:53

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.

share|improve this answer
Hi David, thanks for your help! That tip about going into /usr/share/applications is certainly a time saver compared to deleting the broken links one-by-one in the menu editor. – Alan May 21 '11 at 18:23

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.

share|improve this answer
It's very strange, I've never had this problem until my upgrade to Natty Narwhal. I may downgrade to 10.04LTS, and wait a short while until 11.04 is a little more bug-free. – Alan May 21 '11 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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