Ubuntu – This /usr/bin/dpkg returned error || ubuntu-16.04, 64bit

16.04aptdpkg

I am trying to install htop, but it was failed due to unmet dependencies.
Tried sudo apt-get -f install, but it did not either resolve the issue.

Tried sudo apt clean & sudo apt update, sudo apt upgrade, no luck.
Tried removing the dpkg as well, no luck.

Earlier it was displaying, Could not get lock /var/lib/dpkg/lock so that I have removed it and now it shows below error ain the installation.

Sub-process /usr/bin/dpkg returned an error code (1)

ik@ik-ThinkPad-T440p:~$ sudo apt install htop
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-64-generic : Depends: linux-image-4.4.0-64-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-64-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
ik@ik-ThinkPad-T440p:~$ 
ik@ik-ThinkPad-T440p:~$ sudo apt-get -f install 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  geoip-database-extra javascript-common libc-ares2 libjs-openlayers libnl-route-3-200 libqgsttools-p1 libqt5multimedia5-plugins libqt5multimediawidgets5 libsmi2ldbl libwireshark-data libwireshark6
  libwiretap5 libwsutil6 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-59 linux-headers-4.4.0-59-generic linux-image-4.4.0-21-generic linux-image-4.4.0-59-generic
  linux-image-extra-4.4.0-21-generic linux-image-extra-4.4.0-59-generic wireshark-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  linux-image-4.4.0-64-generic
Suggested packages:
  fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
The following NEW packages will be installed:
  linux-image-4.4.0-64-generic
0 upgraded, 1 newly installed, 0 to remove and 89 not upgraded.
6 not fully installed or removed.
Need to get 21.8 MB of archives.
After this operation, 66.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.nayatel.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-64-generic amd64 4.4.0-64.85 [21.8 MB]
Fetched 21.8 MB in 1min 5s (335 kB/s)                                                                                                                                                                      
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
(Reading database ... 326141 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-64-generic_4.4.0-64.85_amd64.deb ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-64-generic_4.4.0-64.85_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-64-generic /boot/vmlinuz-4.4.0-64-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-64-generic /boot/vmlinuz-4.4.0-64-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-4.4.0-64-generic_4.4.0-64.85_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

These are the output of the commands, please help me fix this.
p:~$ df -H
Filesystem Size Used Avail Use% Mounted on
udev 4.1G 0 4.1G 0% /dev
tmpfs 805M 19M 787M 3% /run
/dev/sda7 293G 14G 264G 5% /
tmpfs 4.1G 201M 3.9G 5% /dev/shm
tmpfs 5.3M 4.1k 5.3M 1% /run/lock
tmpfs 4.1G 0 4.1G 0% /sys/fs/cgroup
/dev/loop0 62M 62M 0 100% /snap/notes/4
/dev/loop3 79M 79M 0 100% /snap/core/1337
/dev/loop2 80M 80M 0 100% /snap/core/1264
/dev/loop1 80M 80M 0 100% /snap/core/1240
tmpfs 805M 62k 805M 1% /run/user/1000

Best Answer

resolved the issue at my own.

removed all the existing packages, with this below Note: before doing this, please to close all the tabs and other sheets as we do not know which process is hurdling the resolution.

1st: sudo apt autoremove

then, sudo apt-get clean then, sudo apt-get -f install then, sudo apt-get update then, sudo apt-get upgrade

And you are done with the fix.

Related Question