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