Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I have installed emacs with apt-get. I tried to remove it later on, but the binary is left.

root@ionian:/home/gauthier# apt-get --purge remove emacs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'emacs' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@ionian:/home/gauthier# which emacs

(the purge shown above is not the first attempt, this is just to show that the package was already removed.)

emacs was not installed before I did apt-get install emacs.

Any idea what is going on? Why doesn't apt-get see the binary, why does it think emacs is already uninstalled? What would have been a clean way to uninstall emacs completely?

share|improve this question
What happens if you run dpkg -S /usr/bin/emacs? – Joseph R. Jul 24 '13 at 21:35
Packages own files but files do not belong to packages. A system usually determines whether or not a package is installed by looking at a database, not by looking for the files the package would own. – Evan Teitelman Jul 24 '13 at 21:37
dpkg-query: no path found matching pattern /usr/bin/emacs – Gauthier Jul 24 '13 at 21:37
@EvanTeitelman: ok, but then why didn't my first attempt of purge clean the binary? Unfortunately I don't have the result of the (most) successful purge anymore. – Gauthier Jul 24 '13 at 21:41
...and file $(which emacs)? – Joseph R. Jul 24 '13 at 21:41

Removing "emacs" do not clean /usr/bin/emacs because the latter is not provided by "emacs" package.

On Debian there are different flavours of emacs so /usr/bin/emacs is a symlink to particular executable that is used by default. You can choose which application to use by running command:

sudo update-alternatives --config emacs

Also package "galternatives" provides nice GUI application to manage alternatives.

If you run aptitude show emacs you may see that "emacs" is a metapackage which merely depends on some other packages that provide emacs executable. When you purged "emacs" it was fully uninstalled but its dependency package(s) may be still present on your system. You can remove them with

sudo apt-get autoremove

or if you use aptitude it will automatically suggest to remove automatically installed packages.

To get rid of /usr/bin/emacs you will have to uninstall all emacs alternatives such as "emacs23" or "emacs24" or any "emacs-*" packages.

Run the following command to find which executables are available as emacs alternatives

update-alternatives --list emacs

Also you may find dlocate utility useful to find which package provides a particular file.

Read more about alternatives in

share|improve this answer
Thanks for this. I remember that some kind of lucid flavour left, although I did run autoremove. This is what I don't understand, autoremove did not seem to remove all dependencies. – Gauthier Jul 27 '13 at 12:48

You may still have emacs23 and friends installed.

sudo apt-get remove emacs*
share|improve this answer

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.