Home Linux troubleshooting Fix ‘E: The package cache file is corrupted, it has the wrong hash’ Error In Ubuntu

Fix ‘E: The package cache file is corrupted, it has the wrong hash’ Error In Ubuntu

By sk
Published: Updated: 17K views

Today, I tried to update the repository lists in my Ubuntu 18.04 LTS desktop and got an error that says - E: The package cache file is corrupted, it has the wrong hash. Here is what I run from the Terminal and its output:

$ sudo apt update

Sample output:

Hit:1 http://it-mirrors.evowise.com/ubuntu bionic InRelease
Hit:2 http://it-mirrors.evowise.com/ubuntu bionic-updates InRelease 
Hit:3 http://it-mirrors.evowise.com/ubuntu bionic-backports InRelease 
Hit:4 http://it-mirrors.evowise.com/ubuntu bionic-security InRelease 
Hit:5 http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu bionic InRelease 
Hit:7 http://ppa.launchpad.net/leaeasy/dde/ubuntu bionic InRelease 
Hit:8 http://ppa.launchpad.net/rvm/smplayer/ubuntu bionic InRelease 
Ign:6 https://dl.bintray.com/etcher/debian stable InRelease 
Get:9 https://dl.bintray.com/etcher/debian stable Release [3,674 B]
Fetched 3,674 B in 3s (1,196 B/s) 
Reading package lists... Done
E: The package cache file is corrupted, it has the wrong hash
The package cache file is corrupted, it has the wrong hash
"The package cache file is corrupted, it has the wrong hash" Error In Ubuntu

After couple Google searches, I found a workaround to fix this error.

If you ever encountered with this error, don't panic. Just run the following commands to fix it.

Warning: Before running the following command, double check you have added "*" at the end. It is very important to add at the end of this command. If you don't add it, it will delete the entire /var/lib/apt/lists/ directory and there is no way to recover it. You have been warned!

$ sudo rm -rf /var/lib/apt/lists/*

Now I tried again to update the system using command:

$ sudo apt update
apt update command output in Ubuntu 18.04
Apt update command output in Ubuntu

This time it works!! Hope this helps.

You May Also Like

6 comments

Dave April 9, 2020 - 1:48 am

Hello, I tried your fix for “E: The package cache file is corrupted, it has the wrong hash”, it didn’t fix it. Now there are many errors when I run apt-get update – issues with the /var/lib/apt/lists directory. Any thoughts?

Reply
sk April 9, 2020 - 11:06 am

Share the error message. I can see what I can do.

Reply
Steve August 13, 2020 - 7:12 am

Fixed it for me. Thanks!

Reply
George Rodriguez October 7, 2021 - 11:02 am

Thanks bro! This works for me on Ubuntu 20.04.3 LTS

Reply
sk October 7, 2021 - 11:32 am

Happy to help.

Reply
Julian January 13, 2022 - 5:40 am

Worked for my error, too. Ubuntu 20.04.2 LTS. Thanks.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More