No command 'bla' found, did you mean:?

For bash, its behavior is governed by the shell function command_not_found_handle (See man bash).

To see what behavior is defined by that function, you can issue:

declare -p -f command_not_found_handle

You can change which program is used by redefining the command_not_found_handle function.

In Debian-based distros (including Ubuntu), the package command-not-found is commonly installed, and available as /usr/lib/command-not-found From the link:

Suggest installation of packages in interactive bash sessions

This package will install handler for command_not_found that looks up programs not currently installed but available from the repositories.

See also:

  • man page for bash, especially COMMAND EXECUTION
  • /usr/share/doc/command-not-found/README (from the Debian package)
  • https://wiki.ubuntu.com/CommandNotFoundMagic

If you look at contents of /etc/apt/sources.list it will have the format

#Archive type  Repository URL                   Distribution Component
 deb           http://archive.ubuntu.com/ubuntu precise      main

Archive type

The first word on each line, deb or deb-src, indicates the type of archive. Deb indicates that the archive contains binary packages (deb), and so on.

Repository URL

The next entry on the line is a URL to the repository that you want to download the packages from.

Distribution

The 'distribution' can be either the release code name / alias (wheezy, jessie, stretch, sid) or the release class (oldstable, stable, testing, unstable) respectively.

What is the meaning of: "(main), (universe)..."?

Component

main consists of DFSG-compliant packages, contrib packages contain DFSG-compliant software, but have dependencies not in main,non-free contains software that does not comply with the DFSG and so on. A tip - Check one of the repository urls,it should have a folder with the name of component.

The package managers say apt will have a database which contains a list of all packages in the repositories and it is smart enough to give you suggestions.

Your package manager may be on eof dpkg(eg Debian, Ubuntu etc), apt(eg Debian, Ubuntu etc), now obsolete rpm(eg older Redhat versions and newer ones don't kick it off for compatibility reasons),yum(eg. Fedora,CentOS),dnf - dentrified yum (eg.New Fedora releases) and so on. For a more comlpete list check this. You might even see are multiple package managers in one distribution. For example in Ubuntu, you may see dpkg which feeds /etc/apt/sources/list.

So when you type

cleaq

It may say

cleaq: no command found. Did you mean clean.

by what means is the "did you mean:" list populated?

This involves a pattern match with the packages in the your package manager database.

This database is updated when you do do an apt-get update

Not sure about

Can I change which program finds these?

though. I believe this is a feature which cannot be changed. Not so sure though

Reference : Debian SourceList