Problem phenomenon
Unpacking nvidia-340 (340.107-0ubuntu0~gpu18.04.1) ... dpkg: error processing archive /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb (--unpack): trying to overwrite '/lib/udev/rules.d/71-nvidia.rules', which is also in package nvidia-kernel-common-396 396.45-0ubuntu0~gpu18.04.2 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
Solution:
Using the following instructions, it will solve the “attempt to overwrite error” with the power of powerful dpkg.
sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-340_340.107-0ubuntu0~gpu18.04.1_amd64.deb //Note that the last /var... .amd64.deb section, which is the path name of the file you reported the error to
Then run the following command to repair any damaged packages.
sudo apt -f install