In Ubuntu Linux, if you attempt to execute a command in the terminal that is not currently installed on your system, you are typically greeted by the command-not-found utility. Instead of a simple error message, this background service actively searches the APT package database and prints out a list of suggested packages that contain the missing command, complete with the exact apt install syntax required to get it.
While incredibly helpful for beginners, this utility can be a significant annoyance for experienced system administrators and developers. The database lookup introduces a noticeable delay—sometimes several seconds—every time you make a simple typo in the terminal. Furthermore, in automated scripting environments or heavily restricted production servers where users should not be attempting to install new software, the helpful suggestions are unnecessary. If you prefer the instantaneous, silent failure of a traditional Unix shell, you can completely disable the command-not-found utility.
Why Disable the command-not-found Utility?
Power users typically remove this feature for the following reasons:
- Terminal Latency: A simple typo (e.g., typing
slinstead ofls) triggers a database search, pausing your workflow while the terminal queries the package cache. - Unnecessary Overhead: The utility requires a locally cached database (updated via
apt-file) which consumes disk space and must be periodically refreshed. - Strict Environments: On immutable infrastructure or production servers, interactive software installation is forbidden, rendering package suggestions useless.
How to Turn Off ‘command-not-found’ in Ubuntu
Because the utility is deeply integrated into the default Bash configuration via a system-wide package, the cleanest way to disable it globally is to remove the package entirely.
- Open your Ubuntu terminal (press Ctrl + Alt + T).
- Execute the following command to completely purge the utility and its associated data files from your system:
sudo apt purge command-not-found command-not-found-data - Press Y and then Enter to confirm the removal.
- Once the uninstallation is complete, the changes will not immediately affect your active terminal session because the Bash hook is already loaded into memory. To apply the change, you must restart your shell.
- Type
exitto close the terminal, and then open a fresh terminal window.
From this point forward, if you type an invalid command, Bash will instantly respond with the standard, zero-latency bash: command not found error, completely bypassing the APT package database lookup.