My recently installed Ubuntu system is currently having issues with the command-not-found hook:

josh@sirius:~$ invalid-command
Unable to open binary database /usr/share/command-not-found/programs.d/i386-main.db: File read error
Unable to open binary database /usr/share/command-not-found/programs.d/i386-multiverse.db: File read error
Unable to open binary database /usr/share/command-not-found/programs.d/i386-restricted.db: File read error
Unable to open binary database /usr/share/command-not-found/programs.d/i386-universe.db: File read error
invalid-command: command not found

I have tried reinstalling and dpkg-reconfigureing both command-not-found{,-data} but these don't seem to have fixed it. Is it safe to delete these files, or do I have to run some program to recreate them? I should add that this was originally a 32-bit install that I reinstalled with 64-bit without formatting the disk.

2 Answers 2


On 20.04.4 LTS, this helped me:

$ sudo apt install --reinstall command-not-found

The -data package is no longer there.

I was getting something like:

$ kbounce
Sorry, command-not-found has crashed! Please file a bug report at:
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.8.5 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
Exception information:

unable to open database file
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
  File "/usr/lib/command-not-found", line 90, in main
    cnf = CommandNotFound.CommandNotFound(options.data_dir)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 79, in __init__
    self.db = SqliteDatabase(dbpath)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 12, in __init__
    self.con = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file

Right now, I get:

$ kbounce

Command 'kbounce' not found, but can be installed with:

sudo apt install kbounce

Edit 2020-12-16

The problem returned after a reboot. I debugged /usr/lib/python3/dist-packages/CommandNotFound/db/db.py and found the following:

$ ls /var/lib/command-not-found/ -l
total 3076
-rw-r----- 1 root root 3141632 gru 16 08:17 commands.db
-rw-r----- 1 root root    3253 gru 16 08:17 commands.db.metadata

So, the DB is there, but the permissions are wrong.

So I executed:

$ sudo chmod -R o+r /var/lib/command-not-found/

Now, it works again.

  • With me, the problem was that import apt_get wasn't working in /usr/lib/python3/dist-packages/CommandNotFound/db/db.py, this answer did the trick!, so symlink apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so.
    – Fee
    May 3, 2021 at 19:09
  • +1 for the chmod. That was all I had to do to fix it.
    – qwerty9967
    Jul 13, 2021 at 20:17
  • You are answering a different question. Aug 15, 2021 at 20:05

The database files for the 64 bit version are named amd64-*.db, while the 32 bit version ones are named i386-*.db. So apparently you have the 32 bit package installed when you should've had the 64 bit package.

What does this output?

apt-cache policy command-not-found{,-data}
  • In here, because apparently I can't format comments nicely: pastebin.com/6fqTMDAn
    – dutchie
    Jul 25, 2013 at 14:01
  • @dutchie, hm. Does this list both amd64-*.db and i386-*.db files? ls /usr/share/command-not-found/programs.d/. If so, it might be the old package just failed to remove those for some reason. So just manually removing them should fix your problem.
    – geirha
    Jul 25, 2013 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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