How to Disable Ubuntu command-not-found

Ubuntu, in all its helpfulness, has a feature that tries to guess what you mean when you type commands at the bash prompt. If you type a command that's found, it runs it, of course. If you type a command that it can't find, it takes a moment to search available packages for install and suggest what you might do to make that command available. It sometimes looks like this:

$ foo
No command 'foo' found, did you mean:
 Command 'xoo' from package 'xoo' (universe)
 Command 'fop' from package 'fop' (universe)
 Command 'fox' from package 'objcryst-fox' (universe)
 Command 'zoo' from package 'zoo' (universe)
 Command 'goo' from package 'goo' (universe)
foo: command not found
It's great when you have a new system and you haven't yet installed everything you need. Type emacs before emacs has been installed, and it will helpfully tell you the exact command to use to install it. After a while, though, you have all the packages you need, and the only time you see this feature in action is when you mistype something. When this happens to me, all the package suggestions and apt-get commands are just annoying. This, for example, is not helpful:
$ les foo.txt
The program 'les' is currently not installed.  You can install it by typing:
sudo apt-get install atm-tools
les: command not found
I'd much rather see this quick, short message so that I can get on with fixing my mistake by adding another 's':
$ les foo.txt
-bash: les: command not found
I finally found how to fix it. Put this line in your .bashrc:
unset command_not_found_handle
Much better.

Comments

Anonymous said…
I just ran "sudo apt-get remove command-not-found" - this helps for all shells and all users.
Anonymous said…
If you just remove the command-not-found package, you won't have an error message at all for a bad command.

Popular posts from this blog

SystemVerilog Fork Disable "Gotchas"

'git revert' Is Not Equivalent To 'svn revert'

SystemVerilog Streaming Operator: Knowing Right from Left