Ubuntu system is broken after accidentally uninstalling many packages

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.


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.

Tags:

Apt

Reinstall