24

For some reason, with my setup, it can take Ubuntu several seconds to respond with "command not found" when I accidentally typo a command. Why does it take so long? Is there any way to shorten the period of time I have to wait?

I do have 13 directories in my PATH, but even so (most of them have just a few files in them), it shouldn't take several seconds to search 13 directories for a command right?

2 Answers 2

34

The shell does more than just looking in $PATH. If a command is not found, the bash function command_not_found_handle is executed which in its turn call the python script /usr/lib/command-not-found. This searches in the packages list for programs that should be installed for the command to work. In the case of a typo which you know how to solve, just press Ctrl + C to abort the search process.

Example of a useful message for a typo:

$ aptget update
No command 'aptget' found, did you mean:
 Command 'apt-get' from package 'apt' (main)
aptget: command not found

Example of a useful message for a missing package:

$ deja-dup
The program 'deja-dup' is currently not installed.  You can install it by typing:
sudo apt-get install deja-dup

See also the rationale behind this, https://wiki.ubuntu.com/CommandNotFoundMagic

2
8

It's because of a package named "command-not-found". You can uninstall it to shorten the response time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .