When you write the command name wrong, bash often does this:

septi@norbert:~$ good
No command 'good' found, did you mean:
 Command 'gold' from package 'binutils' (main)
 Command 'gmod' from package 'gmod' (universe)
 Command 'goo' from package 'goo' (universe)
 Command 'god' from package 'god' (universe)
 Command 'geod' from package 'proj-bin' (universe)
 Command 'gord' from package 'scotch' (universe)
good: command not found

Or sometimes it does this:

septi@norbert:~$ nftp
No command 'nftp' found, but there are 23 similar ones
nftp: command not found

Is there any way to ask bash to show these 23 similar commands for me? And, is there a way to show similar commands, including those that aren't yet installed, instead of running the application, ftp for example?


Solution 1:

Bash uses the command /usr/lib/command-not-found for looking similar commands. This in turn uses Python's CommandNotFound module.

The output you see on the terminal(stderr in this case), is also generated from this module. The location of this module is /usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py, on Ubuntu 14.04 and up. There is a default limit set on number of similar commands in the function CommandNotFound.print_spelling_suggestion(self, word, min_len=3, max_len=15) on line 138. You can modify the max_len value to say 30 (Use sudo nano or gksudo gedit to edit this file).

Solution 2:

It's quite likely that the 23 "similar" commands would not be much more use to you than 'goo', 'god', and 'gord'. The little trick most bash'ers use to find things is to use the man pages since the search is content based rather than just by name. For example, try

man -k ftp

If you find a likely or insteresting command look at the man page itself by dropping the -k switch:

man sftp

man has it's own manual page:

man man

Now you know why, whenever you install a new program or application it very often installs a man page for you as well.

Oh yes, to search in or for man pages you haven't installed yet you might like one of the many online man sites such as this one.