While installing some other package: Installing dependencies: libcurl4-gnutls perl-modules-5.42 REMOVING: came gnash-common gosmore libcupt3-0-downloadmethod-curl libre-engine-re2-perl sheepdog Summary: Upgrading: 122, Installing: 2, Removing: 6, Not Upgrading: 552 13 not fully installed or removed. Download size: 0 B / 16.5 MB Space needed: 3,286 kB / 2,719 MB available Continue? [Y/n] Retrieving bug reports... Done Parsing Found/Fixed information... Done Reading changelogs... Done Extracting templates from packages: 100% (Reading database… 815453 files and directories currently installed.) Removing sheepdog (0.8.3-5+b1)… Failed to stop sheepdog.service: Unit sheepdog.service not loaded. invoke-rc.d: initscript sheepdog, action "stop" failed. dpkg: error processing package sheepdog (--remove): old sheepdog package prerm maintainer script subprocess failed with exit status 1 dpkg: too many errors, stopping Errors were encountered while processing: sheepdog Processing was halted because there were too many errors. needrestart is being skipped since dpkg has failed Error: Sub-process /usr/bin/dpkg returned an error code (1) So let's add some "set -x" to prerm and init scripts: (Reading database… 815453 files and directories currently installed.) Removing sheepdog (0.8.3-5+b1)… + [ -x /etc/init.d/sheepdog ] + invoke-rc.d sheepdog stop Failed to stop sheepdog.service: Unit sheepdog.service not loaded. invoke-rc.d: initscript sheepdog, action "stop" failed. + exit 1 dpkg: error processing package sheepdog (--remove): old sheepdog package prerm maintainer script subprocess failed with exit status 1 dpkg: too many errors, stopping Errors were encountered while processing: sheepdog Processing was halted because there were too many errors. needrestart is being skipped since dpkg has failed Error: Sub-process /usr/bin/dpkg returned an error code (1)