Undo apt-get remove open* ubuntu 12.04

I am running a Linux instance on ec2, snap sorting of image is disabled.

While trying to un-install open-jdk from the system. I stupidly run the command

sudo apt-get remove open*

It started removing many packages, so I stopped the process by Ctrl+C.

I did it twice:

  • sudo apt-get remove open*
  • sudo apt-get remove openjdk*

I stopped the process (Ctrl+C) in between for both of them.

Now I see that my other application are not working, because of the packages removed.

Please advice, how can I go back to the state before apt-get remove.

Thanks in advance.


You can get the information about recently removed packages(What are all the packages that are recently removed) in /var/log/dpkg.log file along with the date and time.

awk '$3=="remove"' /var/log/dpkg.log 

Find and reinstall the packages via apt-get.


If you look into the file /var/log/dpkg.log, you will see all operations regarding packages. So the list of removed packages can be retrieved from this log.

$ LIST=$(grep remove /var/log/dpkg.log|grep -v startup|grep open|awk '{print $4}')
$ sudo apt-get install $LIST

will build a list of package starting by open that were removed, put them in a shell variable and allow you to install them back in one shot.