14

This question already has an answer here:

When I run sudo apt-get update I get four Hash Sum mismatch errors:

W: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/trusty-updates/main/binary-amd64/Packages  Hash Sum mismatch    
W: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/binary-amd64/Packages  Hash Sum mismatch    
W: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/trusty-updates/main/binary-i386/Packages  Hash Sum mismatch    
W: Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/binary-i386/Packages  Hash Sum mismatch

I tried fixing this with

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update 

but that didn't work and neither did

sudo apt-get clean
sudo apt-get update

or

sudo apt-get dist-upgrade
sudo apt-get update

Is there any other way I can try to fix this?

marked as duplicate by wjandrea, Eric Carvalho, karel, Dorian, David Foerster Mar 8 '18 at 20:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

18

Run these commands in terminal 1:

sudo apt-get clean

sudo rm -r /var/lib/apt/lists/*

That worked for me. :-)

Reference

  • 2
    That worked! In order to avoid deleting the lists folder, you should better execute sudo rm -r /var/lib/apt/lists/* – jap1968 Jan 4 '17 at 9:08
2

Usually switching to another mirror does the trick. It's easy in the GUI, but I suspect you want a CLI solution.

sudo sed -i 's|http://us.|http://|g' /etc/apt/sources.list edits your sources.list in-place to use the main server from the US mirror. You can substitute other mirrors, sudo sed -i 's|http://us.|http://fr.|g' /etc/apt/sources.list would choose the french server, starting from the US server.

If you switch to the main server like in the first line, be warned that simple swapping your search and replace terms to get the US mirror back would break your security and extras repos, if you use them. You would need to run a second sudo sed -i 's|http://us.security|http://security|g' /etc/apt/sources.list line to account for that, repeated for extras instead of security.

  • 1
    The second command is iffy, sources.list may have the Canonical extras repository and security.ubuntu.com in it, neither of which have country-specific mirrors. – muru Apr 22 '16 at 20:49
0

Manually download the packages that are getting the Hash Sum Mismatch error and copy them to

/var/cache/apt/archive

Then again run

apt-get install <package-name>

It should now run correctly.

  • This looks like a useful suggestion; however I believe something is required to make apt know about a .deb file manually downloaded into /var/cache/apt/archives - such as making an entry into pkgcache.bin - but I haven't found a way to do this. As things stand I'm getting E: Unable to locate package $pkg – sxc731 Oct 19 '17 at 6:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.