When I type in a nonexistent command my machine stalls for about 5 seconds before returning to the shell prompt
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.
Solution 1:
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.
Solution 2:
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"
Solution 3:
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.