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?
-
1Are you asking what programs offer this functionality or which does it in your case? If the latter, you provided too little information. What shell do you use, for start? – techraf Apr 26 '16 at 02:41
-
I'm using bash but I really just mean in the most general case. What programs provide this and is there a fairly consistent way to determine the program in most shells? – Apr 26 '16 at 02:47
-
It also depends greatly on what flavor/distro of Unix/Linux you're using as to how the feature is implemented. – Randall Sep 22 '17 at 19:28
4 Answers
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:
manpage forbash, especially COMMAND EXECUTION/usr/share/doc/command-not-found/README(from the Debian package)- https://wiki.ubuntu.com/CommandNotFoundMagic
- 415
- 4
- 14
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
- 1,576
- 2
- 13
- 22
-
1@vondirac : Yes sources.list is inside the `/etc/apt`. See the edit.. Well, in general you can say your package manager maintains this list for you and you package manager can be apt(in case of Debian, Ubuntu etc), rpm(Redhat and its clones),yum(eg. Fedora,CentOS) and dnf(New Fedora releases) – sjsam Apr 26 '16 at 03:12
-
You can improve this answer with reference to [some Ubuntu doco](https://wiki.ubuntu.com/CommandNotFoundMagic). – JdeBP Dec 28 '16 at 12:35
police tisn No command police found, did you mean: Command polipo in package polipo Command ionice in package util-linux $
- 1
-
Answers are for, well, answers. This does not answer the original question, it's a clarification request, [so it will be deleted](https://unix.stackexchange.com/help/deleted-answers). You need to earn some reputation before you're allowed to comment, but you should note that poor-quality answers will have a negative effect on what reputation you do have. I'd suggest you delete this yourself. – Peregrino69 Sep 25 '21 at 13:02
-
This does not provide an answer to the question. Once you have sufficient [reputation](https://unix.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://unix.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/389417) – Archemar Sep 26 '21 at 08:28