Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I run the command apt-get install [package_name] and hit CTRL-C mid process, does it stop the installation and roll back to its original state?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

When I upgraded a Ubuntu machine to 12.04, I managed to accidentally close the terminal that was connected to the updating process. Weirdly enough, the process actually continued in background (until it hit a "Do you want to install a new version of this configuration file" prompt and I killed it). This shows that the updating process is written robustly.

Yesterday on a Debian Sid machine I Ctrl+C:ed during an installation. The prompt was returned to me, but Aptitude kept throwing messages about progress to the terminal for a short while, until the action currently in progress was finished.

I believe that Aptitude (which I use, and I would guess that apt-get behaves similarly) tries to handle signals intelligently, and once an action has begun (such as installing/replacing/removing), it will do its best to actually finish this before exiting the process as not to leave the system (and especially the global package configuration state) in an uncertain state.

I tried just now to send Ctrl+C during package downloading, and the package currently being downloaded was interrupted and not saved in a semi-downloaded state. Simply doing a new sudo aptitude dist-upgrade restarted the process at the file that was not correctly downloaded.

That praise being said: if a couple of packages have already been configured, they will not be rolled back to previous versions if the process is interrupted. The best it can do is to quickly clean up, intelligently let you restart the updating process and hopefully start of where you left it. After doing this and all pending actions have been taken, the package state is again "clear" and you can start trying to roll back versions and so on if it is needed.

Final note: don't start depending on this behavior, since it is very rough treatment of the package system and always might lead to package problems (fixable, but often with some manual package downloads and dpkg tinkering).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.