2
sudo apt-get remove tor.

I run the above command yes with . and it showed me do you want to uninstall tor and its components of 973mb and i clicked yes then half way down i realized tor cant be worth that amount so I pressed ctrl+z, and now i cannot see Google Chrome App Store and some other apps.

How can I fix it?

enter image description here

following output of the command which i pressed .

pLumo
  • 26,204
  • 2
  • 57
  • 87
  • Be aware that 14.014 is [EOL](https://askubuntu.com/a/1126933/931617) – schrodingerscatcuriosity Aug 26 '19 at 14:07
  • Time to migrate to a supported release of Ubuntu. – user535733 Aug 26 '19 at 14:09
  • Reinstall all packages that have been removed... Just copy-paste all Packages below "`The following packages will be REMOVED:`". If you closed your terminal, good luck ;-) – pLumo Aug 26 '19 at 14:17
  • 1
    With the new 16.04 tag I'd say this question is on-topic, especially as the same might happen on any `apt`/`apt-get`... – pLumo Aug 26 '19 at 14:20
  • 1
    @DanielMassey that won't work, because `tor.` is recognized as a pattern, and then `apt` will treat it as such and find e.g. `bla-storage-bla` which has nothing to do with `tor`. – pLumo Aug 26 '19 at 14:40
  • Related: [apt-get remove with wildcard removed way more than expected. why?](https://askubuntu.com/q/210976/22949), [Why does apt removes unwanted packages when giving * as suffix?](https://askubuntu.com/q/431604/22949), and [Ubuntu system is broken after accidentally uninstalling many packages](https://askubuntu.com/q/249367/22949) (especially [Andrea Corbellini's answer](https://askubuntu.com/a/249373/22949)) – Eliah Kagan Aug 26 '19 at 15:15

1 Answers1

3

You're lucky, apt-get / apt writes a log at /var/log/apt/term.log.

So you can find all your removed packages and reinstall them.


As you pressed Ctrl+Z, apt-get is a stopped process in the brackground. So, frst of all, you should properly end apt-get. Simply run fg and wait until apt-get is done (Yes that will finish removing the packages, but we will be able to get them back).

For others that might find this answer: If you pressed Ctrl+C instead, you might need to run sudo apt install -f to fix unfinished removals etc.


Then, to get back your packages:

  1. Find out the exact log time

    # If it just happened:
    apt_date=$(sudo grep 'Log started' /var/log/apt/term.log | tail -n1)
    
    # or find manually ...
    sudo less /var/log/apt/term.log
    # ... and set the result as variable, we need in the next step.
    apt_date="Log started: 2019-08-26  16:26:27"
    
  2. Get all removed packages and reinstall them:

    # Get all removed packages for this date and reinstall them:
    sudo sed -n "/${apt_date}/,/Log ended/p" /var/log/apt/term.log \
    | awk '/^Removing/{print $2}' \
    | xargs -r sudo apt install
    
pLumo
  • 26,204
  • 2
  • 57
  • 87