Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 3473  / 3 Years ago, thu, november 18, 2021, 11:00:22

I ran by mistake apt-get remove WRONG_PACKAGE, after realizing this, I pressed CTRL+Z to break the process since removing that package started removing around 100+ other packages.



Now when I try to run apt-get install REMOVED_ONES it states:



E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.


Is there any way to revert it?


More From » apt

 Answers
7

Actually...



CTRL+Z will suspend the process.



CTRL+c will kill the process.



Note that suspending a process will send it to the background until you call it again. Since it is suspended you can run another program. It will "look" like is gone but is not. It will actually tell you the Process ID that has been assigned to it before going to the background.



To know which processes are running on the background we use the jobs command, which would show all background running processes on the opened terminal with their respective background number.



To call the process again (Actually to continue the process where you left it) type fg.



fg means ForeGround. To bring to foreground from background if you want to have an idea of it. If you happen to have other suspended process, you can go to them by doing fg 1 for process 1, fg 2 for process 2 and so on.



Know that if you send a process to the background using CTRL+Z you will send the process to the background but it will be stopped. To make it run again, simply run bg followed by the background ID job for that process, like bg 2 for job 2 in the background.



The difference when applied to apt-get (Or aptitude or any other package manager) is that the lock files will not get erased when doing a remove/upgrade/install or that the repo file might get corrupted.



You will need to literally remove the files with rm.



Before removing anything try what the package manager suggests, in that case:



sudo dpkg --configure -a or sudo dpkg-reconfigure -a in case you did an upgrade. In most cases (in ALL cases for me) I had to first delete the lock files as followed:



sudo rm -fr /var/cache/apt/archives/lock

sudo rm -fr /var/lib/dpkg/lock



If by chance you want to remove the process (if it is still active) you can either look it up by using ps -e and finding the PID numer, then using kill -9 PID where PID is the number you found or issuing sudo killall NAME_OF_PROCESS



Alternative you can also do:



sudo fuser -cuk /var/lib/dpkg/lock

sudo fuser -cuk /var/cache/apt/archives/lock

sudo rm -fr /var/cache/apt/archives/lock

sudo rm -fr /var/lib/dpkg/lock



After all of this you can either use the commands recommended by the app as I mentioned in the beginning or simply try to reinstall the package you mistakenly removed. I also recommend doing an sudo apt-get update just to make sure everything is correct.



Note that if the package removed all of those other packages, try first to install said package. For example if you did:



sudo apt-get remove unity by mistake, then first try to do the steps I mentioned and then install that precise package again:



sudo apt-get install unity.



If by chance it did not get uninstall then do:



sudo -apt-get install --reinstall unity


[#33360] Saturday, November 20, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rontablis

Total Points: 293
Total Questions: 123
Total Answers: 104

Location: Austria
Member since Mon, Mar 1, 2021
3 Years ago
;