1

When I type in a nonexistent command it says "Command not found." and then waits for about 5 seconds before showing the prompt again.

How do I fix that?

I'm using Fedora.

2
  • Does it delay if you type in a command that does exist? May 1, 2010 at 10:38
  • It doesn't ............
    – Kristina
    May 1, 2010 at 10:41

4 Answers 4

5

Check to see that your path doesn't include a 'mount on demand' network share. Also, my Ubuntu installed something that, if you typed the name of a command that existing but you hadn't installed it yet, would say something like 'you need to install package foo'. I don't remember what was doing that, but it obviously would have to do some sort of search through the whole package database, which could be time consuming.

If you're using bash, type 'set' and look for a function called 'command_not_found_handle()'. That's what bash runs when it doesn't find a command.

1
  • 1
    The package on Ubuntu doing this is called command-not-found May 3, 2010 at 5:45
3

This sounds like you have the PackageKit-command-not-found package installed. When this is installed, if you type a command that doesn't exist, it tells you "command not found", and then searches your package repositories to determine if there is a package available that does contain the command you typed. If it finds a package it will prompt you to download it, otherwise it will return you to the command prompt.

If you do not want that functionality, you can remove the PackageKit-command-not-found package by running "sudo yum remove PackageKit-command-not-found"

2

I think Paul's idea about an automount network share in your path is likely where it hangs. The simplest way to see where it hangs is to see what system call the process hangs on. strace is the tool to trace system calls, so for example:

`strace bash -c 'non_existent_command'`
....
stat64("/mnt/remotebin", 0xbfad11e0) = -1 ENOENT (No such file or directory) #Hangs here Maybe?
...

If it is hanging on a automount of something in the path, you could filter the output with:

strace -e trace=stat64 bash -c 'non_existent_command'

But I think the one that shows all the system calls is best to start with.

0

I belive this answer also answers the original question: How do I fix that?

I like the answers on this question, but since I just wanted a quick-fix and do not want to investigate why and I don't want to wait 5 seconds I just created my own function in my own .bash_aliases (sourced in .bashrc) and returned the unknown command to give instant feedback without the wait.

Did the trick for me and I'm happy. Hope it helps someone else.

command_not_found_handle() {
  echo "command not found: ${1}"
}
1
  • You could have just unset the function, i.e. unset -f command_not_found_handle Dec 8, 2020 at 15:12

You must log in to answer this question.

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