Whenever I type sudo apt-get remove and then press the Tab key for auto-completion I get the following message:

grep-status: /var/lib/dpkg/status:15945: expected a colon

I don't see anything especially strange at line 15945 in the status file. It's a dot character in the description field of a mono library package and inserting a colon did not help. Removing the line containing the dot did not work either. Overwriting the file with status-old resulted in the same message.

Is there some way to rebuild the status file?

  • 3
    I don't think you can fully rebuild the status file: it's a primary source of information, and while a lot of it is redundant, not all of it is. However it's probably possible to repair the file manually. Post a chunk of the file around the problematic line, say 20–40 lines including at least one Package: line before and after line 15945. Commented Sep 27, 2010 at 22:22
  • I have since tried uninstalling mono but all it did was change the line number that gets reported as an error. If you follow the paste link, the offending line number is 25, "Section: python" paste.ubuntu.com/501929
    – Ramón
    Commented Sep 28, 2010 at 4:50
  • @Ramón So, apt-get, dpkg and friends still work correctly, and what is erroring out is auto-completion? Commented Sep 29, 2010 at 21:16
  • Correct. It seems to only be having problems parsing the status file when using auto-completion. I can otherwise install and remove packages without any apparent errors.
    – Ramón
    Commented Sep 29, 2010 at 23:09
  • Getting the same problem. I don't think blindly using an old version of apt's database is the right thing to do here regardless of it fixing this problem.
    – Oli
    Commented Oct 6, 2010 at 8:53

8 Answers 8


You should be able to work with a previous known good status file and update from there. Every time you do an install or a update, the status file is saved to a gzipped backup under /var/backups. Doing an ls -l dpkg * on the directory shows:

-rw-r--r-- 1 root root   2266732 2010-09-30 08:35 dpkg.status.0
-rw-r--r-- 1 root root    624182 2010-09-29 08:49 dpkg.status.1.gz
-rw-r--r-- 1 root root    623844 2010-09-28 08:55 dpkg.status.2.gz
-rw-r--r-- 1 root root    620358 2010-09-24 11:04 dpkg.status.3.gz
-rw-r--r-- 1 root root    619021 2010-09-23 15:34 dpkg.status.4.gz
-rw-r--r-- 1 root root    619013 2010-09-23 08:03 dpkg.status.5.gz
-rw-r--r-- 1 root root    618968 2010-09-21 08:33 dpkg.status.6.gz

There's also a backup of the file created in the /var/lib/dpkg/ directory named status-old. Doing an ls -l status* on the directory shows:

-rw-r--r-- 1 root root 2266732 2010-09-30 08:35 status
-rw-r--r-- 1 root root 2267191 2010-09-30 08:35 status-old

So, to recover from a corruption, you should be able to do the following:

1. Make a backup of the corrupt status file:

mv /var/lib/dpkg/status /var/lib/dpkg/status_bkup

2. Copy an recent dpkg status file into place from either of the sources above:


cp /var/lib/dpkg/status-old /var/lib/dpkg/status


cp /var/backups/dpkg.status.#.gz /var/lib/dpkg/
gunzip -d /var/lib/dpkg/dpkg.status.#.gz 
mv /var/lib/dpkg/dpkg.status.# /var/lib/dpkg/status

3. Then run apt-get update:

sudo apt-get update

That should do it.

  • 2
    I did not know about the status files kept in /var/backups. This is good info to have in case it happens again. Thanks, Jim.
    – Ramón
    Commented Oct 5, 2010 at 17:41
  • But is it safe to use an old version? I mean, surely it's not just the auto-complete that uses this file and using an old version with older package information is going to screw other, far more more important things... like apt itself.
    – Oli
    Commented Oct 6, 2010 at 8:45
  • @Oli I am not sure. I've only had to do this once. I think I had to reinstall the app that was causing the problem, but going forward it worked. As with all advice on the Internet (or at least advice from me on the Internet), this worked for me. That doesn't mean that it will necessarily will work for you. I offer it without warranty and without express knowledge of how it will behave on your system. Your mileage may vary. Try at your own risk.
    – Jim
    Commented Oct 6, 2010 at 20:38
  • This solution appears to have fixed my problems. I will update if any issues arise from using an old status file.
    – Matthew
    Commented Aug 20, 2012 at 19:51
  • Old file may be missing some package changes that have done to the system but mostly it will be okay. Doing sudo apt update && sudo apt dist-upgrade should fix most of the problems that old status file might cause. If your system has a bigger mess, sudo aptitude dist-upgrade instead of sudo apt ... may sometimes suggest better ways to fix the breakage. Commented Jul 1, 2019 at 15:25

I have finally fixed my system of this. Restoring a backup of the status file didn't work as I've had the issue for so long, it's in all of my backups.

The fix involves grepping for the actual formatting breaks and fixing them manually. It's not as hard as it sounds.


  • Glad you found a solution, Oli and thanks for sharing. In my case, in addition to the problematic Lexmark deb, a Webmin deb also had its description malformed but in that case it did not cause any parsing issues when doing an autocomplete. Weird.
    – Ramón
    Commented Jan 30, 2011 at 4:44
  • 3
    @Oli are you holder of the licence? Can you write that here?
    – Braiam
    Commented Sep 10, 2013 at 3:39
  • This is true, good that I read your post. I had a missing package name and I found out that, for some weird reason I better not waste my time finding out, I had a line Packaga: landscape-common which was fixed ortographically and bam, problem solved. The thing is, I have never touched this file, nor has anybody else. How can a computer mess up with a spelling mistake?
    – Severo Raz
    Commented Jul 24, 2014 at 0:46
  • The actual answer should be here as well, to avoid it being a link-only answer [if the error's from a blank line that does not precede "Package:" then add a . to that blank line].
    – Xen2050
    Commented Sep 27, 2018 at 1:58

Try a "dpkg -P " for the offending package. That will purge it from the local repository, removing all traces. On my system, that was the fix for removed (but not yet purged) packages that produced that error.


I was able to fix this problem by removing the packages which had corrupted entries in the status file.

sudo dpkg -r handbrake-cli

The accepted solution via pcregrep didn't work (pcregrep didn't find anything).

  • Thank you so much it works for me and in fact it is the right approach Thanks Commented Dec 17, 2014 at 20:31

In this case I would back up the corrupted /var/lib/dpkg/status file and then correct it manually (around the lines 1888 and 9550) using the information from

apt-cache show libssl0.9.8
apt-cache show udev
  • Got it. apt-get is now running smoothly.
    – ændrük
    Commented Mar 9, 2011 at 23:25

This has been a bug (supposed to be fixed): Launchpad Bug 613018

Upstream: Debian Bug 590885

This should be a workaround (backup, "fix" version string):

cp /var/lib/dpkg/status ~/dpkg-status.back
sudo sed -i "s/56127_Ubuntu_karmic/56127Ubuntukarmic/" /var/lib/dpkg/status

Son of a...

Okay, the actual error was on line 15266 despite it being reported some 700 lines further down. The problematic entry in the status file was caused by a deb I installed to get my Lexmark printer working a long time ago. The entry was for the package lexmark-inkjet-08-driver. The Description field did not have a . in the place of a line break. This caused the parsing error.

To find this, I resorted to a shotgun troubleshooting method and started trying things pretty much randomly. One of my goofy attempts was grep-status -P e figuring that e was the most common letter in the alphabet. Dumb, I know, but the last status record printed out before it complained about a missing colon was for the lexmark package and I noticed the lack of a . character after a few minutes of staring at the screen.

If possible, I would like another answer that could describe a better method for finding this sort of issue in case someone runs into a similar problem in the future. Thanks.

  • grep-status -r -P ^ should always match any package so it should parse the whole file and abort if it cannot parse it. Commented Jul 1, 2019 at 15:32

Because my status-old was too problematic even with apt-get update,

This worked pretty well for me:

(as root)

cd /var/lib/dpkg 

cp -avf status status.corrupt

tr -cd '\11\12\15\40-\176' < status.corrupt > status

This command uses the -c and -d arguments to the tr command to remove all the characters from the input stream other than the ASCII octal values that are shown between the single quotes. This command specifically allows the following characters to pass through this Unix filter:

octal 11: tab

octal 12: linefeed

octal 15: carriage return

octal 40 through octal 176: all the "good" keyboard characters

All the other binary characters -- the "garbage" characters in your file -- are stripped out during this translation process.

CREDIT: http://alvinalexander.com/blog/post/linux-unix/how-remove-non-printable-ascii-characters-file-unix

If you're curious what's changed or where would be the damage: (possibly long)

diff /var/lib/dpkg/{status-old,status} |less

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .