[Wylug-help] Slow Internet with Ubuntu 11.04

Smylers Smylers at stripey.com
Sat Sep 3 09:58:47 UTC 2011


T. Noland writes:

> Smylers: How does anyone find out about commands like
> "command-not-found"!? I'm amazed that in the last 24 hours I've been
> introduced to "lspci", "mtr", and now this. I don't know how anybody
> manages even to know they exist!

Well I think you've answered your own question there -- reading this
list seems to be the way that people find out about them!

mtr was also new to me, and lspci I'd forgotten about.

To search for software already installed on your computer, the apropos
command can be useful, for example:

  $ apropos pci

Note that this actually lists man pages, not commands. That means that
commands which don't have man pages (some graphical applications with
their own help systems, for example) aren't list. Though Debian is quite
good at writing token man pages for such commands (which Ubuntu reaps
the benefit of).

And it means that other documented things, such as C libraries or
configuration files, can also be listed in the output. Passing appropos
the option -s 1,8 eliminates those, just listing man pages matching
commands, such as:

  $ apropos -s 1,8 calc

For finding out about packages not installed, there are various commands
which will search the Apt repositories. I generally use aptitude, for
example to find TrueType fonts to install you could try:

  $ aptitude search ttf

(Not all the packages listed are fonts, but the descriptions give a
clue.)

For the specific case of command-not-found, that took a little detective
work -- more than I think is reasonable. Typing in the name of a command
that isn't installed gives a message stating which package it's in, and
a while ago I was curious about how that was happening, and discovered
it's the command_not_found_handle mechanism which Debian added to Bash.
bash(1) gives details, and running env shows that it's running the
program /usr/lib/command-not-found.

More recently, when wanting to know about the packages available to
satisfy a particular alternative, I remembered that command-not-found
lists all the packages a command can be found in, if none are installed.

For example, if no package containing mutt is installed, then running
the mutt command yields:

  The program 'mutt' can be found in the following packages:
  * mutt
  * mutt-patched
  Try: sudo apt-get install <selected package>

If at least one of those packages is installed then of course the mutt
command runs one of them, which is useless for finding out about
alternatives. I realized that if command-not-found could be tricked into
not realizing that mutt is already installed, it would list alternative
packages I might like to try installing.

command-not-found doesn't have a man page, but it does take a --help
option. Pleasingly that reveals the --ignore-installed option, which
does exactly what I wanted.

Cheers

Smylers
-- 
Watch fiendish TV quiz 'Only Connect' (some questions by me)
Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect



More information about the Wylug-help mailing list