Let's suppose I ssh into my computer and run

sudo apt-get dist-upgrade

and, while apt-get is running and installing the packages, another person who is sitting at the terminal and logged into gnome decides to shut-down the computer via the GUI.

What is the worst that can happen under this circumstance? Are there any mechanism that prevents the packages from being left in a 'dirty' state? If not, how to prevent that?

1 Answer 1


Worst case scenario it can break your system making it impossible to boot normaly, but you can always boot into rescue mode and fix it.

  1. Use the rescue mode by booting with an Ubuntu install CDROM and entering “rescue” at the boot prompt

  2. Mount all of your partitions and to perform a chroot to /target where the root partition is mounted.

  3. After the system has booted to the menu, select the item that says “Drop to root shell prompt with networking”. This provides you with the ability to update the software packages from the Internet.

  4. When the prompt appears, start by making sure that all currently installed programs are configured:

    dpkg --configure -a

This may take a long time, depending on how many programs were installed before the system stopped.

  1. Then go ahead and update the current list of packages:

apt-get update

  1. Following this, upgrade the software on the system:

apt-get upgrade

This last step, again, may take a long time to complete. You should pay attention to the list of packages held back (listed at the top of the output from this command); these packages will have to be requested specifically.

Usually, packages are held back because they require new software or other drastic changes: the Linux kernel is always held back. Use a command like this one to install these packages:

apt-get install some-package some-other-package

You may have to repeat this more than once until all of the packages have been installed and none are held back.

Then, you should repeat the update and upgrade in order to completely verify that the system is as updated as it can be:

apt-get update

apt-get upgrade

These last commands should execute quickly, as everything is probably complete – however, it is not impossible that the upgrades would have affected something that requires another upgrade. Not doing this probably won’t matter, but why not do it anyway?

Once done, a reboot is required to make sure that the old software is no longer being used and all that is used is the new upgraded software. Don’t just continue the boot: reboot.

One more thing can be done to clean up afterwards – possibly after the reboot. At a command shell, enter this command to remove unneeded software:

apt-get autoremove


  • This might be a totally new question but is there a easy way to fix it? Like some restore command?
    – giZm0
    Commented Aug 7, 2012 at 13:33
  • 1
    I've updated my answer to include that
    – LnxSlck
    Commented Aug 7, 2012 at 13:33
  • 2
    I would suggest running apt-get dist-upgrade everywhere apt-get upgrade is suggested above. With that, you do not need to manually install packages "held back". Commented Sep 19, 2016 at 6:14

You must log in to answer this question.

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