Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I typed the following in a terminal

$ musique
The program 'musique' is currently not installed. You can install it by typing:
sudo apt-get install musique

So Ubuntu knows that "musique" is a program, although it's currently not installed on the machine. However, if I type

$ musiquez
No command 'musiquez' found, did you mean:
 Command 'musique' from package 'musique' (universe)

it knows that there is no such program called "musiquez".

My question is, how does Ubuntu know this? Where is this information stored about what applications can be installed on Ubuntu?

share|improve this question
up vote 9 down vote accepted

This feature is provided by the command-not-found( Its function is to suggest alternatives and corrections in case of mistyping etc. ) package. Ubuntu installs it by default.

how does it work?

The way it works is through the command_not_found_handle() function in bash. bash provides a hook which is basically a function that is invoked when a command is not found.

If you are more curious, open the /usr/lib/command-not-found file and take a look at the script. It works using the python module CommandNotFound.

enter image description here

share|improve this answer

A pair of packages, command-not-found and command-not-found-data, are what makes this feature work.

command-not-found is simply a handler for the command_not_found_handle() bash function; it searches through the data about the mapping between commands and packages provided by command-not-found-data.

share|improve this answer
I would assume that command-not-found then checks through the local cache of the repositories that is made every time a user runs sudo apt-get update. – nerdwaller Jul 11 '13 at 19:54

You must log in to answer this question.

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