I accidentally removed all the packages starting with the name jpeg with:

sudo apt-get remove jpeg*

This screwed up a lot of things, removed Unity, Firefox, Flash player etc.

I somehow managed to recover the desktop and unity but then a lot of things are still buggy. For example .rpm files and .tag.gz just won't open up at all.

What I want is a way to fix everything that's amiss. Something that is the equivalent of a 'repair installation' with a windows disc.

Any tips, anyone?

  • 1
    I'd really recommend a fresh install. Just backup your /home/ (including invisible files) and insert it in the new installation. Commented Jan 30, 2013 at 12:34
  • 1
  • I don't mean to be patronising, but my tip is to read confirmation messages. apt-get will tell you what it plans to un/install and ask you if that's OK. I get that maybe we're used to just saying 'yeah whatever' because of excessive confirmations in other contexts, but Linux is pretty good about not asking frivolously, and package-management is not a context where you should default to having your guard down. Commented Aug 2, 2020 at 10:39

6 Answers 6


You can install the ubuntu-desktop task:

sudo apt-get install ubuntu-desktop^

This will install all the packages of the standard Ubuntu Desktop you have removed. It won't restore packages you had installed that are not part of the standard desktop (i.e. it will reinstall Unity and Firefox, but not Flash player).

To install those packages, you can look into /var/log/apt/history.log and see exactly what you had removed.

Note: installing the ubuntu-desktop^ task is not the same as installing the ubuntu-desktop package. The first will give APT some hints to resolve dependencies involving virtual packages, the latter will give APT the freedom to choose packages (and will end up installing useless stuff like ubiquity).

Why has the problem happened? apt-get remove jpeg* will not remove all packages starting with jpeg. It will instead remove all packages containing jpe in their name. This is because apt-get works with regular expression, so that jpeg* means: everything containing jpe followed by zero or more g.

  • 1
    Good idea, I hadn't thought of that. I'll be interested to see if it will work here! Commented Jan 30, 2013 at 13:35
  • @EliahKagan: I've tested in a chroot. jpeg* packages only affect some graphical applications, so the necessary 'ingredients' (i.e. NetworkManager for Internet connectivity, APT, terminal emulators and so on) are still on the OP system. Commented Jan 30, 2013 at 13:40
  • @EliahKagan: of course, I made the (non-obvious) assumption that the OP hasn't removed anything else. Commented Jan 30, 2013 at 13:41
  • 2
    Please include a warning to never use tasksel to remove a task - see nasty tasksel-bug
    – guntbert
    Commented Jan 30, 2013 at 14:56
  • 1
    @Attilio: I have explained the difference in the answer. See "Note: installing the ubuntu-desktop^ task is not the same as installing the ubuntu-desktop package ..." Commented May 30, 2015 at 11:34

The best way for you to fix this problem might be to reinstall Ubuntu. (You should back up your documents first, even if you plan to reinstall without reformatting.)

If you do want to try to fix the system in place, then look at the package manager's log files to see what packages were removed, and reinstall them:

  • /var/log/dpkg.log (full information, but hard to read)
  • /var/log/apt/history.log (abbreviated by will tell you every package removed or otherwise modified - likely your best bet)
  • /var/log/apt/term.log (if you removed the packages with apt-get in the terminal, this should show what you saw then, including lists of what packages were going to be removed - so this might be the best way)

Reinstalling just packages whose names start with jpeg won't work, because many (almost certainly most) of the packages that were removed were removed because they relied on those packages.

In the future, I recommend carefully checking the consequences of uninstalling a package. If you're working from the command-line, you'll always be notified. (Unless you use the -y option, in which case, usually not. I recommend against using that option unless you know what you're doing, especially for removals.)

One way to check the consequences of a package management operation carried out with apt-get, without risking them happening, is to run apt-get -s instead of sudo apt-get. This merely simulates the action specified, and reports what packages are would be affected as a result and how.


I run sudo apt-get purge wine* on Ubuntu 15.10, so no graphical interface on boot only terminal login option.

As Eliah Kagan suggested I used info from /var/log/apt/history.log I run nano on history.log and made a simple script that contained sudo apt-get install on all purged packages I found at line :

Purge: evolution:amd64 (3.16.5-1ubuntu3.1), libtotem-plparser18:amd64 (3.10.5-1) ...... etc

But first I had manually to remove text between all : and , including the : ,

at this step a new script would be helpful because the packages were hundreds. after that I run the script and removed a few Unable to locate packages (which I had manually installed). run the script again and thats it. Everything is working fine ... luckily


Install the ubuntu-desktop Install ubuntu-desktop package

sudo apt-get update && sudo apt-get install ubuntu-desktop

It will install necessary packages for your system.

  • this fails for me since the dependencies of ubuntu-desktop are not installed. Commented May 8, 2019 at 1:42

I accidentally removed libssl1.0.0 and my machine was crippled. To restore, I did:

  1. Backup the logs of what was removed cp /var/log/apt/term.log ~/libssl.term.log
  2. Delete the lines unrelated to the libssl action vi ~/libssl.term.log
  3. If networking is missing (can't ping google.com), then reboot in recovery mode and enable networking
  4. Reinstall removed packages cat ~/libssl.term.log | grep ^Removing | sed -e 's/^Removing //g;s/ (.*$//g;/diversion of/d;/dangling symlinks/d' | xargs sudo apt-get -y install

Here is a small python script where you can write the (unusable) package string from your mass uninstall that is on /var/log/apt/history.log. It will output a string that you can copy paste into the apt-get install command in order to easily install all the removed packages.

import re


match =  re.findall(r'([\w\d\.-]+).+? \(.+?\)', apt_str)
print " ".join(match)
  • Commas? Do you mean quotes?
    – wjandrea
    Commented Aug 19, 2018 at 6:54
  • @wjandrea Yes I mean quotes
    – joaoroque
    Commented Aug 20, 2018 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .