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

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
This entry was posted in Advocacy, Fun, Linux, Ubuntu. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

13 Comments

  1. Posted March 20, 2007 at 10:46 pm | Permalink

    Thanks a lot for the tip !

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

      More from author
  2. Posted March 20, 2007 at 1:14 pm | Permalink

    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?

      More from author
  3. Alan Pope
    Posted March 20, 2007 at 2:10 pm | Permalink

    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.

  4. Greg M. Johnson
    Posted March 20, 2007 at 2:02 pm | Permalink

    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.

  5. Posted March 20, 2007 at 2:20 pm | Permalink

    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!

      More from author
  6. Zygmunt Krynicki
    Posted March 20, 2007 at 6:15 pm | Permalink

    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 :-)

  7. Alan Pope
    Posted March 20, 2007 at 11:12 pm | Permalink

    Great tool, thanks for dropping by.

  8. Alan Pope
    Posted March 20, 2007 at 11:11 pm | Permalink

    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.

  9. Posted March 20, 2007 at 9:06 pm | Permalink

    Which meta package pulls it in?

      More from author
  10. Anonymous
    Posted March 20, 2007 at 9:44 pm | Permalink

    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.

  11. Anonymous
    Posted April 7, 2007 at 3:59 am | Permalink

    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!

  12. Anonymous
    Posted April 11, 2007 at 4:40 pm | Permalink

    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.

  13. Alan Pope
    Posted April 11, 2007 at 5:28 pm | Permalink

    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.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType