Command Not Found

I love this new feature in Ubuntu Feisty..

Edit: According to these pages this is also in Ubuntu Edgy (6.10), the current stable release.

If you type a command on Linux that doesn't exist, normally you get this:-

  alan@bishop:~$ mplayer
  -bash: mplayer: command not found

With the package command-not-found installed (which is by default installed as of Ubuntu 7.04 [Feisty] [due out in April]) you get something like this:-

  alan@tigger:~$ mplayer
  The program 'mplayer' can be found in the following packages:
   * mplayer-nogui
   * mplayer
  Try: sudo apt-get install <selected package>
  Make sure you have the 'multiverse' component enabled
  -bash: mplayer: command not found

How cool is that!?

Works for loads of things. There is a database in the dependent package "command-not-found-data".

  alan@tigger:~$ cowsay
  The program 'cowsay' is currently not installed.  You can install it by
  typing:
  sudo apt-get install cowsay
  Make sure you have the 'universe' component enabled
  -bash: cowsay: command not found

  alan@tigger:~$ figlet
  The program 'figlet' can be found in the following packages:
   * figlet
   * toilet
  Try: sudo apt-get install <selected package>
  Make sure you have the 'universe' component enabled
  -bash: figlet: command not found

Of course if you spell the command incorrectly it all goes to pot a bit:-

  alan@tigger:~$ moonbuggy
  -bash: moonbuggy: command not found

  alan@tigger:~$ moon-buggy
  The program 'moon-buggy' can be found in the following packages:
   * moon-buggy
   * moon-buggy-esd
  Try: sudo apt-get install <selected package>
  Make sure you have the 'universe' component enabled
  -bash: moon-buggy: command not found

However if you are following a tutorial or mailing list posting that suggests you run a command that doesn't exist on your system at least it gives you a good way to solve the issue without having to search for the package containing the command.

As with all things it's under development and may have bugs, which can be reported/viewed in launchpad:-

https://launchpad.net/ubuntu/+source/command-not-found/+bugs

Posted In

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Backend sucks...

Did I get that right? It uses the static database from the command-not-found-data package?

Nice for a stable distribution, it should have used apt-file's database to be usable for all distributions.

Anonymous (not verified) | Wed, 2007-04-11 15:40

Good point

But with apt-file you need to update it don't you?

I installed apt-file recently and had to "apt-file update" before "apt-file search /usr/foo/bar" would find anything.

It's not installed by default either, although I guess it could be a dependancy.

Alan Pope | Wed, 2007-04-11 16:28

Package Management

This is pretty sweet I must admit. Nice little features like this are what continue to secure the success of Ubuntu and Linux in general. Nice stuff!

Anonymous (not verified) | Sat, 2007-04-07 02:59

Thanks !

Thanks a lot for the tip !

For me it worked immediatly. I just had to relogin on that shell :)

Tiago Rodrigues (not verified) | Tue, 2007-03-20 22:46

build-essential, compiling packages

this is excellent. As we all know, Ubuntu doesn't ship build-essential or gcc by default. I hope trying someone following instructions, when they type "make", build-essential is installed instead of just gcc....how about the equivalent dependancies that a .configure file complains of too? SOmetimes they're just named differently in Debian repos.

Anonymous (not verified) | Tue, 2007-03-20 21:44
Scott Robinson (not verified) | Tue, 2007-03-20 21:06

It is here..

I have a Virtual Machine which has a basic install of Feisty with no extras. I have installed it and then added the necessary updates. I noted a week or so ago the command-not-found packages arrive, but didn't realise what it was until a few days later when I typed something and the magic happened.

Having a bit of a poke around, it looks like the ubuntu-standard package recommends command-not-found.

Alan Pope | Tue, 2007-03-20 23:11

Thanks :-)

As the upstream author I can't say how happy I am that this little tool is actually usefull to someone. Feel free to file bugs and send patches if something sensible is missing.

I did steal an idea of yours - I'll add checks for misspelled packages. Should ship with fesity + 1 :-)

Zygmunt Krynicki (not verified) | Tue, 2007-03-20 18:15

Hey

Great tool, thanks for dropping by.

Alan Pope | Tue, 2007-03-20 23:12

Whoa. If it is too lame to

Whoa. If it is too lame to understand between misspellings and not-yet-installed packages, it is a reckless thing to add to a user-friendly OS.

Greg M. Johnson (not verified) | Tue, 2007-03-20 14:02

How do I enable this on Edgy?

I've added the package (sudo apt-get install command-not-found), but it doesn't perform as you've demonstrated. Do I need to do anything else?

Roni (not verified) | Tue, 2007-03-20 13:14

There is a readme..

The README is in /usr/share/doc/command-not-found/README and says:-

To use it please add the following line to your .bashrc file:
. /etc/bash_command_not_found

(actually it says add ". /etc/bash_command_nof_found" but that has already been reported as a bug:- https://bugs.launchpad.net/ubuntu/+source/command-not-found/+bug/94088)

You will need to start a new terminal or logout and login again for that change to take effect I suspect.

Alan Pope | Tue, 2007-03-20 14:10

Of course! There's a README! (slaps forehead)

I'm still sort of a newbie, so I'm still not used to reading the docs as soon as installing something new.

Works like a charm, anyway.

Thanks!

Roni (not verified) | Tue, 2007-03-20 14:20

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options