20Mar Command Not Found
My machine’s BASH has just received a brand new upgrade! From now on, whenever I type a command to open some application which is not installed in my Ubuntu system, the repositories are automatically scanned and, if there is an application with the given name, it will be suggested for installation.
Confused? Here’s an example, I’ll try to open gedit, which is not installed:
tiagoboldt@Niath:~$ gedit
The program ‘gedit’ is currently not installed. You can install it by typing:
sudo apt-get install gedit
bash: gedit: command not found
tiagoboldt@Niath:~$
This feature should be installed by default, but you can also install it through the command-not-found package, available in the repositories.
Edit:
There has been some discussion about how fast the output comes out, if it slow or not, so, see it for yourself:
tiagoboldt@Niath:~$ time kedit
The program ‘kedit’ is currently not installed. You can install it by typing:
sudo apt-get install kedit
Make sure you have the ‘universe’ component enabled
bash: kedit: command not foundreal 0m0.154s
user 0m0.108s
sys 0m0.028s
Less than 0.2 seconds, yes, it is fast!


March 20th, 2007 at 9:34 pm
command-not-found is part of the default install in the upcoming ubuntu feisty release. smart move on their part to include such a handy tool.
March 21st, 2007 at 3:03 pm
Good greif - there you go being psychic. I have to admit, it is handy to have that available (not that you’d know I was geeky from my URL *rolls eyes*)
and I’m a girl - we’re a rare breed *winks*
–
http://www.madspace.co.uk
March 21st, 2007 at 3:05 pm
wow, I can see why people love ubuntu so much, they put alot of thought into making it easier to use.
March 21st, 2007 at 3:09 pm
doesn’t work with 6.06, package command-not-found not found
March 21st, 2007 at 3:27 pm
i’ve installed this but it doesn’t seem to work unless i run
$ command-not-found gedit
shouldn’t this execute automagically upon failure to locate a command?
March 21st, 2007 at 3:34 pm
J. Morris:
Ensure you’ve re-logged before expecting command-not-found to work.
March 21st, 2007 at 3:40 pm
you install all, or almost every, programs with apt-get, this really only helps you the first time (if you didn’t know about apt-get). Seems like a waste to me to be reminded about apt-get every time.
March 21st, 2007 at 3:54 pm
@IronmanBrian: It’s not always as easy as you put it. For example, if a app is part of a larger bundle (gnome-games comes to mind, or gnome-system-tools) command-not-found gives you the bundle package, and it also mentions if you need Universe/Multiverse repos.
March 21st, 2007 at 4:04 pm
And how long before people start posting on the Ubuntu forums ‘When I try to run $appname I get the error “$appname is not installed, you can install it by typing…’ What do I do?”
March 21st, 2007 at 4:14 pm
Let’s leave the apocalyptic comments and stick to reality. When a problem appears, a solution must come out. this package does that. So, let’s stick to this solution and try to solve each problem by itself.
March 21st, 2007 at 4:22 pm
Why dont they just pop up a browser window with the package manager ready to go “OMG, click here to install !”
March 21st, 2007 at 4:58 pm
Too bad it doesn’t use aptitude.
People new to the system, who sees this message, might just think that apt-get is an application. IT IS NOT. It is a showcase of libapt.
Aptitude has one BIG advantage. When you ‘aptitude remove’ the program it knows what dependencies was installed with the program - and also remove those. Apt-get just removes the ‘top’ package, and thus leaves a lot of other stuff in the system.
Maybe I should file a bugreport…
March 21st, 2007 at 5:39 pm
Let’s hope there’s an /etc/command-not-found.conf that lets you pick aptitude over apt-get. Perhaps I should check out Ubuntu’s launchpad.
March 21st, 2007 at 5:44 pm
Well, in Fedora, don’t know about Ubuntu. I often have to go /sbin/”command” for a lot of those command-not-found ie. /sbin/modprobe and /sbin/iwconfig
though wlanconfig doesn’t need it.
Hope that enlightens someone.
March 21st, 2007 at 5:54 pm
Wow, that is amazing. And default in Feisty!
March 21st, 2007 at 7:13 pm
Doesn’t it slow down anything?
March 21st, 2007 at 7:49 pm
@Love Calculator: It does! At least my (feisty powered) laptop needs a second or so to print out this stuff. Truly nothing I would activate on a slow machine, but it’s nice anyway.
March 21st, 2007 at 8:01 pm
Well… why doesn’t it just say:
“Command not found. Would you like to install it? Yes No”
March 21st, 2007 at 9:09 pm
@brent -
I think it probably would be easier by default if it WOULD do that. I don’t usually try to type in the commands of programs I don’t want to install so I agree.
Command not found.
Would you like to install it?(Y)es/No
Password: lawlercake§
Downloading …
March 21st, 2007 at 10:29 pm
You don’t have to log out to get this to work. Just close and open a new terminal. Pretty easy. Very nice. Now this is a must have on all my Ubuntu boxes.
March 30th, 2007 at 11:16 pm
Great!!
Work very fine!
April 4th, 2007 at 6:03 am
Personally, I find it rather annoying. Not to say that it’s not useful, but I rarely, if ever type a program that’s not installed. Granted, I’m a reasonably advanced user, but you need to be somewhat advanced to be mucking about in the terminal in the first place. It most often comes up when I make a typo, and since my system isn’t the speediest out there, it’s a nuisance to always have it saying “The program ’sl’ is not currently installed…”. This would be compounded if it actually asked me to install it each time.
That said, it was easy enough to remove, and I can see how it could come in handy.
April 11th, 2007 at 5:44 pm
Does it really use the static data from command-not-found-data as backend? Nice for a stable, useless for all other distributions.