Skip to main content

how to install NMAP on unix and linux systems

Installing Nmap on Unix and Linux systems

Most popular Linux distributions provide binary Nmap packages which allow for
simple installation. Installation on Unix systems requires compiling Nmap from
source code .

At the time of this writing Nmap version 5.00 was not available for
automatic installation on some Linux distributions. For many, installing
Nmap via the popular apt or yum package managers will only install
Note

version 4.x. If your distribution already has Nmap 5.00 in their
repositories you can install Nmap by using the commands listed below.
Otherwise,  to install Nmap 5.00 from source code(steps are given down to instal nmap from source).
Installing Precompiled Packages for LinuxFor Debian and Ubuntu based systems
# apt-get install nmap
For Red Hat and Fedora based systems
# yum install nmap
For Gentoo Linux based systems
# emerge nmap

To check which version of Nmap you are running, type the following command on
the command line:

# nmap -V
Nmap version 5.00 ( http://nmap.org )
25Compiling Nmap from Source for Unix and Linux
Currently, the only way to get Nmap 5.00 for most Unix and Linux systems is to
download and compile the source code from the nmap.org website. Building Nmap
from source takes a little extra work, but is well worth the effort to get the new
features in Nmap’s latest release. The following five steps detail the procedure for
installing Nmap from source.
Step 1
Download the Nmap 5.00 source from www.nmap.org/download.html. This can be
done via a standard web browser or from the command line using the wget
command found on most Unix based systems.
$ wget http://nmap.org/dist/nmap-5.00.tgz
--2009-08-06 19:29:35--
http://nmap.org/dist/nmap-5.00.tgz
Resolving nmap.org... 64.13.134.48
Connecting to nmap.org|64.13.134.48|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9902346 (9.4M) [application/x-tar]
Saving to: `nmap-5.00.tgz'
100%[================================>] 9,902,346 1.39M/s in 7.5s
2009-08-06 19:29:42 (1.27 MB/s) - `nmap-5.00.tgz' saved
[9902346/9902346]
Downloading Nmap on Unix and Linux systems via the command line
Step 2
Extract the contents of the Nmap package by typing tar -xf nmap-5.00.tgz.
$ tar -xf nmap-5.00.tgz
...
Extracting Nmap source code
Step 3
Configure and build the Nmap source code by typing cd nmap-5.00/ and then
./configure && make on the command line.
$ cd nmap-5.00/
$ ./configure && make
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
...
Compiling Nmap source code
Step 4
Install the compiled code by typing sudo make install on the command line.
This step will require root privileges. You must login as the root user or
Note
use the sudo command to complete this step.
$ sudo make install
Password: ********
/usr/bin/install -c -d /usr/local/bin /usr/local/share/man/man1
/usr/local/share/nmap
/usr/bin/install -c -c -m 755 nmap /usr/local/bin/nmap
/usr/bin/strip -x /usr/local/bin/nmap
/usr/bin/install -c -c -m 644 docs/nmap.1 /usr/local/share/man/man1/
/usr/bin/install -c -c -m 644 docs/nmap.xsl /usr/local/share/nmap/
...
NMAP SUCCESSFULLY INSTALLED
$
Installing Nmap from source code
Step 5
Once Nmap has been successfully installed, you can verify it is working correctly by
executing nmap localhost on the command line.
$ nmap localhost
Starting Nmap 5.00 ( http://nmap.org ) at 2009-08-07 00:42 CDT
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Interesting ports on e6400 (127.0.0.1):
Not shown: 993 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
139/tcp open netbios-ssn
445/tcp open microsoft-ds
631/tcp open ipp
2049/tcp open nfs
Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
Nmap test scan on Unix/Linux
If the results of your scan are similar to the results above, then you have successfully
installed Nmap. If you receive an error, comment in Q/A arena