No command ‘bla’ found, did you mean:?

So, when a command is not found, by what means is the “did you mean:” list populated?
What program finds these alternate commands?
What is the meaning of: “(main), (universe)…”?
Can I change which program finds these?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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:

Method 2

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

Method 3

This is not a standard feature of Linux shells. There are at least two possibilities:

  • zsh is maintaining its own suggestion list
  • project thefuck offers another one

Method 4

police tisn
No command police found, did you mean:
Command polipo in package polipo
Command ionice in package util-linux
$


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x