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.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
a.smith
  • 705
  • 4
  • 13
  • 28

6 Answers6

32

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.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
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
Roman Czyborra
  • 484
  • 2
  • 4
  • 1
    Nice, but note that this works in `bash` but not in other shells (I tried `tcsh` and `zsh`) – arielf Apr 03 '17 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.

Joakim
  • 306
  • 1
  • 6
  • 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. – Stephen Kitt Mar 31 '17 at 12:39
  • 1
    In Debian can work also like `apt search pkgname` – George Vasiliou Mar 31 '17 at 12:41
  • @StephenKitt Correct! – Joakim Mar 31 '17 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 Apr 03 '17 at 08: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). – Stephen Kitt Apr 03 '17 at 09: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.

Stephen Rauch
  • 4,209
  • 14
  • 22
  • 32
silver
  • 11
  • 1
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