Whenever you cannot find executables on a Red Hat based distro and you know their names, you should do 1 of the following 2 things.
Use repoquery
You can search the YUM repositories that are available to your system by using the command repoquery
. If it isn't installed, then do a yum install yum-utils
.
$ repoquery -qf */nmap
nmap-2:6.40-4.el7.x86_64
From here you can see which packages have an executable with those names. Here's all of them at once.
$ repoquery -qf */netstat */lsof */nmap
net-tools-0:2.0-0.17.20131004git.el7.x86_64
ctdb-tests-0:2.5.1-2.el7.x86_64
lsof-0:4.87-4.el7.x86_64
nmap-2:6.40-4.el7.x86_64
ctdb-tests-0:2.5.1-2.el7.x86_64
Now just do a sudo yum install lsof
or sudo yum install nmap
to install these missing packages.
Use yum search
You can also do a similar search using yum search <executable>
.
$ yum search netstat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.advancedhosters.com
* extras: mirror.cisp.com
* updates: centos-mirror.jchost.net
================================================================== Matched: netstat ==================================================================
dstat.noarch : Versatile resource statistics tool
net-snmp.x86_64 : A collection of SNMP protocol tools and libraries
net-tools.x86_64 : Basic networking tools
With this approach you'll need to do a bit of digging to confirm that the resulting packages include the executable you're looking for. I typically look in there lit of files for what I want, but for that you'll have to use repoquery
.
$ repoquery -ql net-tools.x86_64 | grep netstat
/bin/netstat
/usr/share/man/de/man8/netstat.8.gz
/usr/share/man/fr/man8/netstat.8.gz
/usr/share/man/man8/netstat.8.gz
/usr/share/man/pt/man8/netstat.8.gz
So using my first approach saves you the extra steps.
netstat's deprecation
Apparently in CentOS 7 netstat
, which is part of the package net-tools
has been officially deprecated, so you should be using ss
(part of the package iproute2), going forward.