5

When I want to remove a program, sometimes I get an error telling me to wait until apt-get stops running, but it doesn't; no matter how long I wait I get the same error. So I have restart the computer.

Is there a way to stop the apt-get process?

2
  • 1
    What tells you to wait? Jul 27, 2016 at 12:30
  • 5
    Could you please edit your question to include some example output to show us this message you get and what exactly you are trying to do.
    – user364819
    Jul 27, 2016 at 12:32

3 Answers 3

8

If you wish to:

  • End a process do: CTRL + C
  • Kill a process do: CTRL + U

Though you should note that interrupting apt-get/apt in the middle of a package installation or removal can cause problems later on and could even corrupt your system and make it unbootable (depending on the package) so it is something which is highly inadvisable to do.

Especially by just powering down your system, that is total interruption of what it is doing, at least with the end shortcut the program can choose what to do in such a circumstance and may have a cleaner exit which allows it to resume later on (so it may take a few moments for this shortcut to work, please be patient at least for this).

If you wish later on to resume apt-get you may run either of these commands:

  • sudo apt-get install -f
  • sudo dpkg --configure -a
9
  • What's the difference between ending and killing a process?
    – mizech
    Jul 27, 2016 at 13:30
  • As far as I know, you should be OK as long as it is in the Downloading process and not actually doing anything with the downloads. This is the case even for upgrades too (I am pretty sure on this.. however dangerous this advice is). Another option is to install with a -d option. This will only download the packages but not install them. This is a pretty good way to go when networks are slow. It can be done with upgrade or even dist upgrade. sudo apt update -d for example. I speak from experience and my network speeds are much faster now so I do not use this option much these days. Jul 27, 2016 at 13:36
  • @BhikkhuSubhuti: But the OP specifies package removal so there is unlikely to be anything needing downloading during this process. But that is a good point.
    – user364819
    Jul 27, 2016 at 13:44
  • @st88: Ending it asks it politely to end, but allows it to have a clean exit (or as clean as possible), it basically just tells the program it should close, the program can then do whatever it wants with that request. Killing it just stops it then and there.
    – user364819
    Jul 27, 2016 at 14:01
  • How did you know what type of wait OP asks? It's totally unclear. apt-get remove doesn't wait until it is finished, unlike apt-get install which sometimes causes downloading of external programs.
    – Anwar
    Jul 27, 2016 at 14:01
3

Ctrl + C will simply send a SIGINT signal to apt-get which will by default cause process to terminate. Also, I don't recommeded you to do this.

(Not recommdend in any scenarios)Ctrl+\ will allow you to send SIGQUIT signal to apt-get which force the process to terminate and create a dump.

If network drops , you should use Ctrl + Z to suspend the process in the background and then use fg %1 (%x , value of x can be different).

Also, if you are getting too much time taken by apt-get then you should remove/deactivate some of the PPAs you don't require using software updates program. (I have personally deactivated webup8 PPA because I don't want upgrade a higher Oracle JDK version.) After, deactivating PPAs, apt-get will ignore deactivated PPAs.

Note: Removing PPAs should be handled with care.

enter image description here

3

Sure. Just use the keyboard shortcut CTRL+C

That will tell the process to end.


However...

As @ByteCommander notes in the comments:

I just want to add that partially installed or removed packages can get you into trouble. You should not simply kill apt-get just fir the fun of it, it might bite you later.

I personally have bricked a VM before by stopping apt-get.

3
  • 1
    I just want to add that partially installed or removed packages can get you into trouble. You should not simply kill apt-get just fir the fun of it, it might bite you later.
    – Byte Commander
    Jul 27, 2016 at 12:37
  • @ByteCommander - Although the OP just shutting down probably isn't good either :) Jul 27, 2016 at 12:38
  • i bricked my main Debian installation yesterday. spend this entire day setting up my new os Dec 2, 2019 at 19:48

Not the answer you're looking for? Browse other questions tagged .