System Servicesbashpackage-suggestioncommand-handlerapt

command-not-found

Suggests installation of packages in interactive bash sessions for commands not currently installed but available from repositories. Installs a handler for command_not_found that looks up available programs.

Description

The command-not-found tool enhances interactive bash sessions by providing helpful suggestions when users attempt to run commands that are not installed on the system. It checks repositories for matching packages and recommends installation, streamlining the process of discovering and installing missing utilities on Kali Linux.

This package is particularly useful for users new to Kali or Linux environments, as it reduces frustration from 'command not found' errors by automatically identifying available packages. It integrates seamlessly with apt and relies on cached data for quick lookups.

The tool includes a companion utility, update-command-not-found, to refresh its cache using apt-file data, ensuring suggestions remain current with repository changes.

How It Works

The package installs a bash handler for the command_not_found hook. When an unknown command is executed, the handler queries a local cache built from /var/cache/apt/apt-file data, which lists commands provided by repository packages. It suggests matching packages for installation via apt. The cache is updated by update-command-not-found using apt-file, with options to skip apt-file update.

Installation

bash
sudo apt install command-not-found

Flags

--versionshow program's version number and exit
-h, --helpshow this help message and exit
-d DATA_DIR, --data-dir=DATA_DIRuse this path to locate data fields
--ignore-installedignore local binaries and display the available packages
--no-failure-msgdon't print '<command-name>: command not found'
-h, --helpPrint the help message for update-command-not-found
-n, --no-apt-fileDo not run apt-file update before updating the cache for update-command-not-found

Examples

Shows the help message and usage for command-not-found
command-not-found -h
Displays the program's version number and exits
command-not-found --version
Looks up 'colly' using a custom data directory path
command-not-found -d /custom/path colly
Ignores locally installed binaries and shows available packages for 'copy-router-config'
command-not-found --ignore-installed copy-router-config
Queries 'somecommand' without printing the 'command not found' failure message
command-not-found --no-failure-msg somecommand
Updates the command-not-found cache using apt-file data
update-command-not-found
Updates the cache without running apt-file update first
update-command-not-found -n
Shows help for the update-command-not-found utility
update-command-not-found -h
Updated 2026-04-16kali.org ↗