How to disable command-not-found in Ubuntu
If you make a typo on the command line in Ubuntu, or if you type the name of a command that doesn’t exist, the system will automatically provide you with a list of commands that are similar to what you entered; or, if the command exists but the package it belongs to is not installed, it will provide you with the name of the package that you need to install to get that command. However, this feature does slow down the shell, and if you use the command line often, it does get to be annoying. This article will show you how to disable the command suggestion feature in Ubuntu.
8SQHVUP4GCZ8
Just so we’re all on the same page, this is the feature I am going to disable:
This is what happens if you make a typo typing a command; it will try to give you a “command spell check”:
No command ‘picco’ found, did you mean:
Command ‘pico’ from package ‘nano’ (main)
Command ‘pico’ from package ‘alpine-pico’ (universe)
picco: command not found
Or, if you type a command that does exist, but is not installed:
The program ‘vim’ can be found in the following packages:
* vim
* vim-gnome
* vim-tiny
* vim-gtk
* vim-nox
Try: apt-get install <selected package>
There are two things you need to do to disable this feature. The first is to remove the package that provides the feature, and the second is to do a quick workaround to bypass a bug which makes the package removal only partially complete.
Step one: Remove the command-not-found package.
If you try executing a non-existent command now, you’ll see that you’ll get a Python error, as shown below. This is because of the bug referenced above.
/usr/bin/python: can’t find ‘__main__.py’ in ‘/usr/share/command-not-found’
Step Two: To work around this bug, we simply need to run the following command:
You need to restart your shell for the change to take affect, but once you open a new terminal you’ll see the classic “command not found” bash error:
bash: picco: command not found
If, in the future, you decide that you want to re-enable the command suggestion, here is how:
sudo mv /usr/share/command-not-found.bak /usr/share/command-not-found
That’s all it takes — just close your terminal and open it again, and you will have the command suggestion available again.
Like this post?
- Subscribe to the RSS feed to get more like it!
- Share it:
- Leave a comment!




You can do the same thing more simply, in one step:
sudo apt-get remove command-not-found command-not-found-data
The “/usr/share/command-not-found” directory is in the “command-not-found-data” package, which is a dependency of the “command-not-found” package.
Well. Removing a package from a system for a single user’s sake is an obvious sign of dictatorship.
Just add the following line in your ~/.bashrc:
unset command_not_found_handle
Not so well, it doesnt work. At least on my ubuntu 10 command
env | grep -i ‘command\|found\|handle’
gives nothing. But i agree, there must be a way to just disable the feature without resorting to uninstall.
command_not_found_handle is implemented as a Bash shell function, but the function is not exported. To check to see if you have it enabled, run
set | grep “command_not_found_handle”
not when it’s the dumbest package ever
i did this, but then commands (like mc)
which is not installed, but exists
gave no errors
replying to myself
but the other suggestion does work
unset command_not_found_handle
thanks