18

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?

George Udosen
  • 36,677
jss367
  • 479
  • I used the commands sudo rm -rf /var/lib/apt/lists/* then sudo apt-get update -o Acquire::CompressionTypes::Order::=gz before it worked for me (https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1785778) – wordsforthewise Dec 02 '19 at 21:14

3 Answers3

29

Run these commands in terminal 1:

sudo apt-get clean

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

That worked for me. :-)

Reference

George Udosen
  • 36,677
vahid-dan
  • 458
  • 3
    That worked! In order to avoid deleting the lists folder, you should better execute sudo rm -r /var/lib/apt/lists/* – jap1968 Jan 04 '17 at 09: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.

emk2203
  • 4,166
  • 1
  • 21
  • 47
  • 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.

TheOdd
  • 3,012
ice
  • 1
  • 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 06:54