Why a long delay after command not found?

Often when I mistype a command such as ls (e.g. I hit ENTER before I type ‘s’) there is a long (~2s) delay after the terminal displays:

bash: l: command not found...

I can understand the reasons for a similar delay after an incorrect password is entered, per Why is there a big delay after entering a wrong password?. But why delay after an unrecognized command? Does FAIL_DELAY in /etc/login.defs affect this also?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

after some research I have found this:

  • try to uninstall the command-not-found package with $>yum remove command-not-found then install it again with >$yum install command-not-found (just in case you have that package installed on your system).

if that doesn’t help try:

  • add this to your ~/.bashrc file:

    unset command_not_found_handle

Method 2

I found that the best solution, at least on Fedora, is to modify the configuration file
/etc/PackageKit/CommandNotFound.conf

as the biggest delay comes from the search for packages to install, if you modify
SoftwareSourceSearch=true in SoftwareSourceSearch=false

the delay is almost 0 and you still get warned about misspellings, which can be useful.

Method 3

Fedora uses something similar.

If you want to just remove this feature use:

yum remove PackageKit-command-not-found

Method 4

In my case it’s because of some known proxy bug in /usr/libexec/pk-command-not-found

Failed to search for file: cannot update repo 'updates':
Cannot prepare internal mirrorlist:
Curl error (28): Timeout was reached for https://mirrors.fedoraproject.org/metalink?repo=updates-released-f28&arch=x86_64 
[Connection timed out after 30002 milliseconds]

My proxy configuration is correct because downloading the exact same URL with a bare curl command succeeds instantly.

I checked the pk-command-not-found process does have the proxy configuration:

tr  '' 'n' < /proc/$(pgrep -f pk-command-not-found)/environ | grep -i proxy

However it does not use it for some unknown reason.

https://bugzilla.redhat.com/show_bug.cgi?id=1553368


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x