0

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

1

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 <jak@debian.org>
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.