sudo apt purge emacs* removed ubuntu-desktop, shotwell etc

I wanted to do a fresh install of emacs so I tried to uninstall everything related to emacs using:

sudo apt purge emacs*

Here is the output:

$ sudo apt purge emacs*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'emacsen' for glob 'emacs*'
Note, selecting 'emacs-snapshot-nonx' for glob 'emacs*'
Note, selecting 'emacs-calfw-howm' for glob 'emacs*'
Note, selecting 'emacs24-lucid' for glob 'emacs*'
Note, selecting 'emacspeak-espeak-server' for glob 'emacs*'
Note, selecting 'emacs25-dbg' for glob 'emacs*'
Note, selecting 'emacspeak' for glob 'emacs*'
Note, selecting 'emacs-snapshot' for glob 'emacs*'
Note, selecting 'emacs25-lucid' for glob 'emacs*'
Note, selecting 'emacs-goodies-el' for glob 'emacs*'
Note, selecting 'emacs22-common' for glob 'emacs*'
Note, selecting 'emacs25-nox' for glob 'emacs*'
Note, selecting 'emacs25-nox-dbg' for glob 'emacs*'
Note, selecting 'emacs-jabber' for glob 'emacs*'
Note, selecting 'emacs23-nox' for glob 'emacs*'
Note, selecting 'emacs25-bin-common' for glob 'emacs*'
Note, selecting 'emacs25-common' for glob 'emacs*'
Note, selecting 'emacs-intl-fonts' for glob 'emacs*'
Note, selecting 'emacs-mozc' for glob 'emacs*'
Note, selecting 'emacspeak-bs-tcl' for glob 'emacs*'
Note, selecting 'emacsen-common' for glob 'emacs*'
Note, selecting 'emacs-nox' for glob 'emacs*'
Note, selecting 'emacs25-common-non-dfsg' for glob 'emacs*'
Note, selecting 'emacs' for glob 'emacs*'
Note, selecting 'emacs25-el' for glob 'emacs*'
Note, selecting 'emacs-window-layout' for glob 'emacs*'
Note, selecting 'emacs-mozc-bin' for glob 'emacs*'
Note, selecting 'emacs-chess' for glob 'emacs*'
Note, selecting 'emacs23-lucid' for glob 'emacs*'
Note, selecting 'emacs-snapshot-gtk' for glob 'emacs*'
Note, selecting 'emacs25-lucid-dbg' for glob 'emacs*'
Note, selecting 'emacs24-nox' for glob 'emacs*'
Note, selecting 'emacs24-bin-common' for glob 'emacs*'
Note, selecting 'emacs-goodies-extra-el' for glob 'emacs*'
Note, selecting 'emacspeak-dt-tcl' for glob 'emacs*'
Note, selecting 'emacs20' for glob 'emacs*'
Note, selecting 'emacs21' for glob 'emacs*'
Note, selecting 'emacs22' for glob 'emacs*'
Note, selecting 'emacs23' for glob 'emacs*'
Note, selecting 'emacs24' for glob 'emacs*'
Note, selecting 'emacs25' for glob 'emacs*'
Note, selecting 'emacs26' for glob 'emacs*'
Note, selecting 'emacs-calfw' for glob 'emacs*'
Note, selecting 'emacspeak-dt' for glob 'emacs*'
Note, selecting 'emacspeak-ss' for glob 'emacs*'
Package 'emacs24' is not installed, so not removed
Package 'emacs-snapshot' is not installed, so not removed
Note, selecting 'emacs-goodies-el' instead of 'emacs-goodies-extra-el'
Package 'emacs26' is not installed, so not removed
Package 'emacs23' is not installed, so not removed
Package 'emacs20' is not installed, so not removed
Package 'emacs21' is not installed, so not removed
Package 'emacs22' is not installed, so not removed
Package 'emacspeak-bs-tcl' is not installed, so not removed
Package 'emacspeak-dt' is not installed, so not removed
Package 'emacspeak-dt-tcl' is not installed, so not removed
Package 'emacs-chess' is not installed, so not removed
Package 'emacs24-bin-common' is not installed, so not removed
Package 'emacs24-lucid' is not installed, so not removed
Package 'emacs24-nox' is not installed, so not removed
Package 'emacs22-common' is not installed, so not removed
Package 'emacs23-nox' is not installed, so not removed
Package 'emacs23-lucid' is not installed, so not removed
Package 'emacs-snapshot-gtk' is not installed, so not removed
Package 'emacs-snapshot-nonx' is not installed, so not removed
Package 'emacs' is not installed, so not removed
Package 'emacs-goodies-el' is not installed, so not removed
Package 'emacs25' is not installed, so not removed
Package 'emacs25-dbg' is not installed, so not removed
Package 'emacs25-lucid-dbg' is not installed, so not removed
Package 'emacs25-nox' is not installed, so not removed
Package 'emacs25-nox-dbg' is not installed, so not removed
Package 'emacs-calfw' is not installed, so not removed
Package 'emacs-calfw-howm' is not installed, so not removed
Package 'emacs-intl-fonts' is not installed, so not removed
Package 'emacs-jabber' is not installed, so not removed
Package 'emacs-nox' is not installed, so not removed
Package 'emacs-window-layout' is not installed, so not removed
Package 'emacspeak' is not installed, so not removed
Package 'emacspeak-espeak-server' is not installed, so not removed
Package 'emacspeak-ss' is not installed, so not removed
Package 'emacs25-common-non-dfsg' is not installed, so not removed
Package 'emacs-mozc' is not installed, so not removed
Package 'emacs-mozc-bin' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  activity-log-manager libgeonames-common libgeonames0 liblockfile-bin liblockfile1 libm17n-0 libnm-gtk0 libotf0
  libtimezonemap-data libtimezonemap1 libunity-control-center1 m17n-db xaw3dg
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  apturl* aspell* aspell-en* chrome-gnome-shell* deja-dup* dictionaries-common* emacs25-bin-common* emacs25-common*
  emacs25-el* emacs25-lucid* emacsen-common* enchant* gdm3* gedit* gir1.2-webkit2-4.0* gnome-calendar* gnome-control-center*
  gnome-getting-started-docs* gnome-initial-setup* gnome-online-accounts* gnome-shell* gnome-software*
  gnome-software-plugin-snap* gnome-user-docs* gnome-user-guide* gufw* hunspell-en-us* hyphen-en-us* indicator-bluetooth*
  libedataserverui-1.2-2* libenchant1c2a* libgoa-backend-1.0-1* libgspell-1-1* libwebkit2gtk-4.0-37* libyelp0* mutter*
  mythes-en-us* nautilus-share* rhythmbox-plugins* shotwell* ubuntu-desktop* ubuntu-docs* ubuntu-release-upgrader-gtk*
  ubuntu-session* ubuntu-software* unity-control-center* update-manager* update-notifier* wbritish* yelp* zenity*
0 upgraded, 0 newly installed, 51 to remove and 0 not upgraded.
After this operation, 241 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 336156 files and directories currently installed.)
Removing nautilus-share (0.7.3-2ubuntu3) ...
Removing apturl (0.5.2ubuntu14.2) ...
Removing ubuntu-desktop (1.417.3) ...
Removing gufw (18.04.0-0ubuntu1) ...
Removing shotwell (0.28.4-0ubuntu1) ...
Removing gnome-software-plugin-snap (3.28.1-0ubuntu4.18.04.12) ...
Removing aspell-en (2017.08.24-0-0.1) ...
update-default-aspell: Removing remove file "/var/lib/aspell/en.remove".
Removing aspell (0.60.7~20110707-4) ...
Removing chrome-gnome-shell (10-1) ...
Removing deja-dup (37.1-2fakesync1ubuntu0.1) ...
Removing wbritish (2017.08.24-1) ...
Removing mythes-en-us (1:6.0.3-3) ...
Removing emacs25-lucid (25.2+1-6) ...
Remove dictionaries-common for emacs25
remove/dictionaries-common: Purging byte-compiled files for flavour emacs25
Remove emacsen-common for emacs25
emacsen-common: Handling removal of emacsen flavor emacs25
Removing emacs25-bin-common (25.2+1-6) ...
Removing emacs25-el (25.2+1-6) ...
Removing emacs25-common (25.2+1-6) ...
Removing enchant (1.6.0-11.1) ...
Removing gdm3 (3.28.3-0ubuntu18.04.4) ...
Removing gedit (3.28.1-1ubuntu1.2) ...
Removing gnome-calendar (3.28.2-0ubuntu0.18.04.1) ...
Removing unity-control-center (15.04.0+18.04.20180216-0ubuntu1) ...
Removing gnome-getting-started-docs (3.28.2-0ubuntu0.1) ...
Removing gnome-initial-setup (3.28.0-2ubuntu6.16.04.6) ...
Removing gnome-online-accounts (3.28.0-0ubuntu2.1) ...
Removing ubuntu-session (3.28.1-0ubuntu3) ...
Removing gnome-shell (3.28.4-0ubuntu18.04.1) ...
Removing gnome-user-guide (3.28.2+git20180715-0ubuntu0.1) ...
Removing gnome-user-docs (3.28.2+git20180715-0ubuntu0.1) ...
Removing hyphen-en-us (2.8.8-5) ...
Removing libedataserverui-1.2-2:amd64 (3.28.5-0ubuntu0.18.04.2) ...
Removing ubuntu-docs (18.04.4) ...
Removing yelp (3.26.0-1ubuntu2) ...
Removing libyelp0:amd64 (3.26.0-1ubuntu2) ...
Removing mutter (3.28.4-0ubuntu18.04.1) ...
Removing rhythmbox-plugins (3.4.2-4ubuntu1) ...
Removing ubuntu-software (3.28.1-0ubuntu4.18.04.12) ...
Removing zenity (3.28.1-1) ...
Removing gnome-software (3.28.1-0ubuntu4.18.04.12) ...
Removing libgspell-1-1:amd64 (1.6.1-1) ...
Removing indicator-bluetooth (0.0.6+17.10.20170605-0ubuntu3) ...
Removing gnome-control-center (1:3.28.2-0ubuntu0.18.04.5) ...
Removing libgoa-backend-1.0-1:amd64 (3.28.0-0ubuntu2.1) ...
Removing update-notifier (3.192.1.7) ...
Removing update-manager (1:18.04.11.10) ...
Removing ubuntu-release-upgrader-gtk (1:18.04.34) ...
Removing gir1.2-webkit2-4.0:amd64 (2.24.4-0ubuntu0.18.04.1) ...
Removing libwebkit2gtk-4.0-37:amd64 (2.24.4-0ubuntu0.18.04.1) ...
Removing libenchant1c2a:amd64 (1.6.0-11.1) ...
Removing hunspell-en-us (1:2017.08.24) ...
Removing dictionaries-common (1.27.2) ...
Removing 'diversion of /usr/share/dict/words to /usr/share/dict/words.pre-dictionaries-common by dictionaries-common'
Removing emacsen-common (2.0.8) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for install-info (6.5.0.dfsg.1-2) ...
Processing triggers for cracklib-runtime (2.9.2-5build1) ...
Processing triggers for libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.4) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
(Reading database ... 328258 files and directories currently installed.)
Purging configuration files for deja-dup (37.1-2fakesync1ubuntu0.1) ...
Purging configuration files for wbritish (2017.08.24-1) ...
Purging configuration files for unity-control-center (15.04.0+18.04.20180216-0ubuntu1) ...
Purging configuration files for gufw (18.04.0-0ubuntu1) ...
dpkg: warning: while removing gufw, directory '/etc/gufw' not empty so not removed
Purging configuration files for dictionaries-common (1.27.2) ...
Purging configuration files for emacsen-common (2.0.8) ...
Purging configuration files for gdm3 (3.28.3-0ubuntu18.04.4) ...
Removing user `gdm' ...
Warning: group `gdm' has no more members.
userdel: user gdm is currently used by process 1272
/usr/sbin/deluser: `/usr/sbin/userdel gdm' returned error code 8. Exiting.
Could not remove gdm user.
/usr/sbin/delgroup: `gdm' still has `gdm' as their primary group!
Could not remove gdm group.
Purging configuration files for update-notifier (3.192.1.7) ...
Purging configuration files for gnome-software (3.28.1-0ubuntu4.18.04.12) ...
Purging configuration files for aspell-en (2017.08.24-0-0.1) ...
Purging configuration files for gnome-initial-setup (3.28.0-2ubuntu6.16.04.6) ...
Removing user `gnome-initial-setup' ...
Warning: group `nogroup' has no more members.
Done.
Purging configuration files for chrome-gnome-shell (10-1) ...
Purging configuration files for indicator-bluetooth (0.0.6+17.10.20170605-0ubuntu3) ...
Processing triggers for systemd (237-3ubuntu10.29) ...
Processing triggers for dbus (1.12.2-1ubuntu1.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
ureadahead will be reprofiled on next reboot

I did not read the whole package list during confirmation, usually it doesn't act this way. But looking at the uninstall log I found a lot of things other than emacs being removed. I tried opening the software center just to check and it didn't work.

I tried installing emacs again afterwards using

sudo apt install emacs

And emacs25 was installed as expected.

Is there any way to get back all of my applications which were removed other than installing them manually?


The command you issued (and confirmed) caused to uninstall all packages that depended on any package matching the emacs* glob expression.

You should be able to reinstall all of them semi-automatically the following way:

From the log included in your question, copy and save the list of packages to remove as a file, let’s call it pkg-list.txt

$ cat pkg-list.txt
  apturl* aspell* aspell-en* chrome-gnome-shell* deja-dup* dictionaries-common* emacs25-bin-common* emacs25-common*
  emacs25-el* emacs25-lucid* emacsen-common* enchant* gdm3* gedit* gir1.2-webkit2-4.0* gnome-calendar* gnome-control-center*
  gnome-getting-started-docs* gnome-initial-setup* gnome-online-accounts* gnome-shell* gnome-software*
  gnome-software-plugin-snap* gnome-user-docs* gnome-user-guide* gufw* hunspell-en-us* hyphen-en-us* indicator-bluetooth*
  libedataserverui-1.2-2* libenchant1c2a* libgoa-backend-1.0-1* libgspell-1-1* libwebkit2gtk-4.0-37* libyelp0* mutter*
  mythes-en-us* nautilus-share* rhythmbox-plugins* shotwell* ubuntu-desktop* ubuntu-docs* ubuntu-release-upgrader-gtk*
  ubuntu-session* ubuntu-software* unity-control-center* update-manager* update-notifier* wbritish* yelp* zenity*

Then use the following command to remove the asterisk after each package name and pass the list to sudo apt install:

< pkg-list.txt sed 's/\*//g' | xargs sudo apt install

Note: After this, all the packages will be marked as installed manually although many of them had been installed automatically originally. Their original configuration was deleted by apt purge command.

Lesson: Always read carefully what’s going on when the system asks for confirmation (or produces an error message).