1

On some Linux installations, there is a 'feature' in which bash automatically suggests similar commands or apt packages when you type a command which is not found on the path.

I find it very annoying, as this takes several seconds and blocks the terminal.

Where is this configured (bash, Ubuntu)? Where can I change/disable this? I just want the errormessage of an unknown command and nothing more.

Cannot find anything inside ~/.bashrc .

This is the output (takes 10 seconds) on my corporate machine, shortened:

> eco 'hello world'

Command 'eco' not found, did you mean:

  command 'ecj' from deb ecj (3.16.0-1)
  command 'ecc' from deb ecere-dev (0.44.15-1build3)
[...]
  command 'co' from deb rcs (5.9.4-6)
  command 'ico' from deb x11-apps (7.7+8)
  command 'peco' from deb peco (0.5.1-1)
  command 'ecm' from deb gmp-ecm (7.0.4+ds-5)

Try: apt install <deb name>

> 
1

1 Answer 1

2

On Debian (and Ubuntu etc), this is done by the command-not-found package. To stop it, remove the package.

apt-get purge command-not-found

IIRC, you will have to exit and restart your current shell (or logout and login again, or reboot) for the command_not_found_handle function to be reset after you remove the package. Or just run unset -f command_not_found_handle in every running interactive shell (e.g. every tab in your terminal emulator).

BTW:

Package: command-not-found
Version: 23.04.0-1
Installed-Size: 522
Maintainer: Julian Andres Klode <[email protected]>
Architecture: all
Depends: apt-file (>= 3.0~exp1~), lsb-release, python3-apt, python3:any
Suggests: snapd
Description-en: Suggest installation of packages in interactive bash sessions
 This package will install a handler for command_not_found that looks up
 programs not currently installed but available from the repositories.

PS: You're not the only one who finds this annoying. I uninstall it from every system I build. I purge the bash-completion package too, I find the restrictions and delays caused by custom completions to be far more annoying than the benefits.

2
  • 1
    Thanks! Yes that helps and seems to be the clean way. Now I get only one line eco: command not found . Mar 14 at 8:50
  • Thanks for this too - and thanks for asking the question @Blindleistung. When they added it in fedora I was really annoyed but I rarely use the system except in ssh these days so I didn't bother doing anything about it. It is slow and almost always it's because I made a typo I already know about. It's bordering on babysitting the user and I'm inclined to say it IS babysitting and it's extremely obnoxious. BTW in fedora and probably other RH systems the package is PackageKit-command-not-found. Oh and I don't think I had to log out either but one might have a different experience of course.
    – Pryftan
    May 1 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .