19

In case there were some problems during the last apt-get operation, is there a command that checks if something has to be continued in apt-get?

rubo77
  • 32,486
  • 2
    If you get a dpkg lock error, see here. – Wilf Feb 24 '14 at 11:23
  • apt-get doesen't suggest anything here, but aptitude does, but a very strange suggestion on my laptop: http://askubuntu.com/questions/425516/aptituse-problem-using-mariadb-on-ubuntu-13-10-32bit – rubo77 Feb 24 '14 at 11:59
  • Depends where it was interrupted. Sometimes you interrupt dpkg sometimes you interrupt apt-get. apt-get itself can be interrupted any time since it's just an frontend for dpkg, dpkg otherwise is not for some operations. – Braiam Feb 24 '14 at 16:04
  • If you're going down the rabbit hole through sudo dpkg --configure some-package and you encounter that SOME process is using SOME file sudo lsof /path/to/file can give you PIDs of the processes to kill PID – jave.web May 16 '23 at 18:55

3 Answers3

28

Use the command:

sudo apt-get -f install

If that doesn't work, you can direct dpkg to finish setting up any packages that were only partially set up:

sudo dpkg --configure -a

If it doesn't work than you can reconfigure all the packages with:

sudo dpkg-reconfigure -a
Wil
  • 805
Frantique
  • 8,493
  • 4
    I think reconfiguring all packages is not such a good idea and takes hours of manual work – rubo77 Feb 24 '14 at 11:51
  • is it the same with sudo aptitude -f install? – rubo77 Feb 24 '14 at 11:52
  • @rubo77: no, it is not the same but something similar. – Frantique Feb 24 '14 at 12:02
  • On my problem the -f doesent make any difference, woth or without, I get no errors with apt-get but with atṕtitude, see: http://askubuntu.com/questions/425516/aptituse-problem-using-mariadb-on-ubuntu-13-10-32bit – rubo77 Feb 24 '14 at 12:04
  • Forget about aptitude, that works a little bit different. – Frantique Feb 24 '14 at 12:46
  • 2
    Is it possible that you meant dpkg --configure -a? That's a subset of what apt-get -f … does if there are unconfigured packages. dpkg-reconfigure is an entirely different operation. – David Foerster May 26 '18 at 16:22
  • Don't recommend apt -f install - in certain scenarios it can purge your system from all software... – jave.web May 16 '23 at 16:53
8

In addition to the response by @Frantique, I would like to add:

sudo dpkg --configure -a

That solved my issue when the upgrade was interrupted during the process.

Jose Gómez
  • 558
  • 1
  • 5
  • 19
2

I had the same issue and in my case a Deb package was corrupted. I had to

  1. delete the cached packages from /var/cache/apt/archives with

    sudo apt-get clean
    
  2. before running

    sudo apt-get -f install
    
David Foerster
  • 36,264
  • 56
  • 94
  • 147