Sunday, May 5, 2024
34
rated 0 times [  34] [ 0]  / answers: 1 / hits: 1614  / 3 Years ago, sun, october 24, 2021, 7:17:25

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?


More From » command-line

 Answers
0

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


[#42510] Sunday, October 24, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aradxalte

Total Points: 70
Total Questions: 116
Total Answers: 116

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
;