Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – Gilles Sep 27 '10 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" – Ramón Sep 28 '10 at 4:50
@Ramón So, apt-get, dpkg and friends still work correctly, and what is erroring out is auto-completion? – Riccardo Murri Sep 29 '10 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 Sep 29 '10 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 Oct 6 '10 at 8:53
up vote 7 down vote accepted

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.

share|improve this answer
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 Jan 30 '11 at 4:44
@Oli are you holder of the licence? Can you write that here? – Braiam Sep 10 '13 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 Jul 24 '14 at 0:46

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.

share|improve this answer
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 Oct 5 '10 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 Oct 6 '10 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 Oct 6 '10 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 Pirocchi Aug 20 '12 at 19:51

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
share|improve this answer
Got it. apt-get is now running smoothly. – ændrük Mar 9 '11 at 23:25

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).

share|improve this answer
Thank you so much it works for me and in fact it is the right approach Thanks – user2671192 Dec 17 '14 at 20:31

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.

share|improve this answer

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
share|improve this answer

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.

share|improve this answer

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.


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

diff /var/lib/dpkg/{status-old,status} |less
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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