[Ubuntu] How I resolved E: The package cache file is corrupted
by Riley MacDonald, April 2, 2018

Upon attempting to update my Lubuntu (Ubuntu 17.10) system I observed the following error:

$ sudo apt update
[sudo] password for user: 
Hit:1 http://security.ubuntu.com/ubuntu artful-security InRelease
Hit:2 http://packages.microsoft.com/repos/vscode stable InRelease              
Hit:3 http://ca.archive.ubuntu.com/ubuntu artful InRelease                     
Hit:4 https://dl.yarnpkg.com/debian stable InRelease                           
Hit:5 http://ca.archive.ubuntu.com/ubuntu artful-updates InRelease             
Hit:6 http://ca.archive.ubuntu.com/ubuntu artful-backports InRelease           
Hit:7 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease  
Reading package lists... Error!                    
E: Read error - read (5: Input/output error)
W: You may want to run apt-get update to correct these problems
E: The package cache file is corrupted

Running sudo apt-get update or sudo apt clean didn’t resolve the problem. After doing some research I determined the corrupted files were located in /var/lib/apt/lists/. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#var:

Holds dynamic data libraries/files like the rpm/dpkg database and game scores. Furthermore, this hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users shouldn’t ever need to modify files in /var/lib to configure a package’s operation. State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. An application (or a group of inter-related applications) use a subdirectory of /var/lib for their data. There is one subdirectory, /var/lib/misc, which is intended for state files that don’t need a subdirectory; the other subdirectories should only be present if the application in question is included in the distribution. /var/lib/’name’ is the location that must be used for all distribution packaging support. Different distributions may use different names, of course.

Clearing everything from the /lists/ seems to have safely resolved the issue for me. Be careful not to delete the lists directory as I’ve read they’re not recreated by the system.

$ sudo rm -rf /var/lib/apt/lists/*
$ sudo apt update
Open the comment form

Leave a comment:

Comments will be reviewed before they are posted.

User Comments:

Steve. on 2023-03-17 02:02:32 said:
This is a great fix and it worked for me too - I'm very happy! Many thanks to you and best wishes.

woo on 2021-12-09 08:48:11 said:
you bet it works! Thanks

balu dommeti on 2021-09-09 14:18:57 said:
Hi i have tried to remove the items from /var/lib/apt/lists/* and tried update but still getting the same issue any alternatives ?

J Das on 2020-06-12 19:20:57 said:
It works perfectly. Will know more as days go by. I'm Hoping it is the fix that i have been waiting for. Thanks a lot Riley.

Maria on 2020-05-27 03:41:47 said:
Thank you. This worked like a charm!

seshagiri rao on 2019-09-26 08:56:24 said:
Hi Riley, I have is same problem and I did type the above mentioned commands to see if the error message would resolve the issue. but It does not. Do you have any Idea? seshagiri@seshagiri-Inspiron-3646:~$ sudo apt-get update Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://ny-mirrors.evowise.com/ubuntu bionic InRelease Hit:3 http://ny-mirrors.evowise.com/ubuntu bionic-updates InRelease Hit:4 http://ny-mirrors.evowise.com/ubuntu bionic-security InRelease Hit:5 http://dl.google.com/linux/chrome/deb stable Release Hit:6 http://archive.canonical.com/ubuntu bionic InRelease Reading package lists... Error! E: Unable to parse package file /var/lib/dpkg/status (1) W: You may want to run apt-get update to correct these problems E: The Package cache file is corrupted.

Ivan on 2019-03-22 07:46:04 said:
Thanks, that was very helpful!