30

Sometimes you run a command and get a "command not found" error message.

After that you try to install the package that contains that command (I think that's what happens anyway?)

e.g. showmount: command not found

apt-get install showmount does nothing, so I guess the showmount command is part of a package, but I don't know what that package is.

How can I find out what package I need to install to get whichever command I need? I am using Kali Linux.

0

6 Answers 6

33

You can use apt-file for that (you might need to install it):

apt-file search showmount

This reveals that the command is in the nfs-common package.

Typically when you're looking for a binary you can restrict the search by prefixing the binary with bin/:

apt-file search bin/showmount

To install apt-file, run

sudo apt-get install apt-file
sudo apt-file update

If you end up with apt-file 3.0 or later, you won’t need to update the indexes again separately (after the initial download above), they are updated whenever the main APT indexes are updated.

0
20

You might want to ease your life by installing the command-not-found helper

$ sudo apt install command-not-found
[…]
$ showmount
Command 'showmount' is available in '/sbin/showmount'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative priviledges associated with your user account.
showmount: command not found
1
  • 1
    Nice, but note that this works in bash but not in other shells (I tried tcsh and zsh)
    – arielf
    Commented Apr 3, 2017 at 19:05
19

You can use apt-cache, which is included as default on debian based distributions (afaik):

apt-cache search showmount

which gives the result nfs-common as well.

5
  • 2
    That works in this case (and is a good idea anyway), but it only finds words mentioned in a package’s name and description, so it’s unfortunately not applicable generally. Commented Mar 31, 2017 at 12:39
  • 1
    In Debian can work also like apt search pkgname Commented Mar 31, 2017 at 12:41
  • @StephenKitt Correct!
    – Joakim
    Commented Mar 31, 2017 at 14:26
  • both apt-cache search showmount and apt search showmount have me the result i was looking for. @StephenKitt when i use apt-file search showmount it says update cache despite already running apt-file update. That is why i have asked Joakims answer.
    – a.smith
    Commented Apr 3, 2017 at 8:47
  • That’s fine, I hope you don’t mind that I edited your question to make its title more specific as a result (since the accepted answer doesn’t work in general). Commented Apr 3, 2017 at 9:03
1

Browse over to http://packages.debian.org or http://packages.ubuntu.com under the 'Search the contents of packages' section. You can find the package that contains the file you need without installing other apt tools.

0

I faced the same issue while mounting nfs server. In my case just run the following command.

sudo showmount -e [ip address of the nfs server]

I forgot to write sudo.

-1

Run the following commands,

  • # apt update
  • # apt install rpcbind nfs-common

You must log in to answer this question.

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