Skip to main content

Finding the package which provides a given command [Resolved]

If the package command-not-found is installed and a user tries to run a command which is not present on the system, a suggestion is printed with the name of the package which provides the executable. Is there a command with the same functionality but which takes the name of an executable as an argument?

Edit: I have read How to find out which (not installed) Debian package a file belongs to? but none of the suggestions present a command which gives an unambiguous result like command-not-found.


Question Credit: August Karlstrom
Question Reference
Asked July 18, 2019
Tags: debian
Posted Under: Unix Linux
31 views
2 Answers

You can use command-not-found itself:

command-not-found --ignore-installed ls

will tell you which package contains the ls command. (--ignore-installed avoids taking into account installed packages, and in particular ensures that the command isn’t run immediately if it’s already installed.)

Alternatively, you can use apt-file:

apt-file search bin/ls

will list all packages containing a file whose path contains “bin/ls”. You can filter this to match only ls:

apt-file search bin/ls | grep bin/ls$

credit: Stephen Kitt
Answered July 18, 2019
Your Answer