This answer is copied from this article.
As you can see in the error message, some packages have unmet dependencies. That means there are some mixing in third-party dependencies. APT package manager is easy to use for installing, removing etc but while mixing with third-party dependencies, apt-get sometimes gives this kind of error that you're getting.
Please follow the steps:
Take a backup of configuration files like:
/etc/apt/sources.list
Now remove the corrupt package database first:
sudo apt-get clean
or
sudo apt-get autoclean
Now please run this:
sudo apt-get -f install
This is most basic command to fix dependencies issues.
Now run:
sudo dpkg --configure -a
then,
sudo apt-get -f install
See the output, if its like this: 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
then it means it failed.
Now run this:
sudo apt-get -u dist-upgrade
If it shows any held packages then you have to eliminate it by this command:
sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
Again see the output. If it's like this:
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
That means it failed again.
Now you have to delete the held packages one by one by running dist-upgrade
each time. Use --dry-run
and be aware of each incidents.
sudo apt-get remove --dry-run package-name
If not any luck then you have to find and remove the dependencies by yourself.
Disable PPA's:
Open Software Center > Edit > Software Sources and click on Other Software. You will see that each PPA have two lines, one for the compiled packages and one for the source, Uncheck both lines to disable a PPA.
Purge:
It means downgrading the packages in the selected PPA to the version in the official Ubuntu repositories and disabling that PPA. Run this command:
sudo apt-get install ppa-purge
If the above fails then run this:
mkdir ppa-purge && cd ppa-purge && wget http://mirror.pnl.gov/ubuntu/pool/universe/p/ppa-purge/ppa-purge_0.2.8+bzr56_all.deb && wget http://mirror.pnl.gov/ubuntu//pool/main/a/aptitude/aptitude_0.6.6-1ubuntu1_i386.deb && sudo dpkg -i ./*.deb
Use PPA Purge:
sudo ppa-purge ppa:someppa/ppa
Remove:
Run the commands:
sudo apt-get autoremove --purge package-name
sudo add-apt-repository --remove ppa:someppa/ppa
sudo apt-get autoclean
After that try again.
Read the original article and your concept will be much more clear.
Another method:
Show all installed packages with "linux-" and contains a number.(edit as your requirement):
dpkg -l linux-* | awk '/^ii/{ print $2 }' | grep -e [0-9]
Now specify the name of packages that you want to purge:
sudo apt-get -y purge linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic linux-headers-3.13.0-29 linux-headers-3.13.0-29-generic linux-image-3.13.0-24-generic linux-image-3.13.0-29-generic linux-image-extra-3.13.0-24-generic linux-image-extra-3.13.0-29-generic
Alternative command:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
This is the advanced command, which removes all kernel except the latest one.
You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: linux-headers-3.13.0-88-generic : Depends: linux-headers-3.13.0-88 but it is not going to be installed linux-image-extra-3.13.0-93-generic : Depends: linux-image-3.13.0-93-generic but it is not going to be installed linux-image-generic : Depends: linux-image-3.13.0-93-generic but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
– user494556 Aug 22 '16 at 07:01