What causes bash to pause after a bad command?

Solution 1:

This type of behavior is caused by a tool frequently installed on some distributions that hook into bash. This hook makes it so that if you try to run a command, and the command doesn't exist, then bash will search the files available in the configured repositories, and tell you what package you would need to install to get that command.

If you are not on a Debian system you'll want to look at your bash startup files profiles and so on and see if anything defines the function named command_not_found_handle. If that bash function is defined, then it will be called whenever you run a command and an appropriate program cannot be found in your search path. If you run typset | less and browse through the output you will see the command_not_found_handle() function if it has been defined.

On Debian/Ubuntu the package that provides this behavior is command-not-found. If you purge that, then you will disable the lookups which does slow things down.

Here is an example

# command-not-found installed
$ time pwgen
The program 'pwgen' is currently not installed.  To run 'pwgen' please ask your administrator to install the package 'pwgen'
pwgen: command not found

real    0m0.074s
user    0m0.032s
sys     0m0.040s

# purge command-not-found and restart bash
$ time pwgen
-bash: pwgen: command not found

real    0m0.002s
user    0m0.000s
sys     0m0.000s

The exact time would of course be different for you. I ran my tests on a pretty beefy server.

Solution 2:

Part of the question was "is there a way to fix this (in Fedora)?" There is: at the bottom of your .bashrc file add the command

unset command_not_found_handle

You probably want to do it at the end of your .bashrc (or close to it) because you might be running /etc/bashrc or other bash scripts at the top of your .bashrc.