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,947

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,947