How do I install the latest version of nmap from source on Ubuntu?

I am not that familiar with nmap but I built the very latest version from source reasonably easily under Xenial Xerus with a few easy steps.

Step 1:

First activate the Software Sources:

Dash > Software & Updates > Ubuntu Software > Downloadable from The Internet > Source Code

and allow the Repositories to reload.

Step 2:

Then install the build dependencies as well as checkinstall:

sudo apt-get build-dep nmap
sudo apt-get install checkinstall

Step 3:

Then run the following single command to download, compile and install the latest nmap:

mkdir $HOME/Desktop/nmap_build && cd $HOME/Desktop/nmap_build && \
wget https://nmap.org/dist/nmap-7.31.tar.bz2 && tar xavf nmap-7.31.tar.bz2 && \
cd nmap-7.31 && \
./configure && make && \
sudo checkinstall --pakdir "$HOME/Desktop/nmap_build" \
     --backup=no --deldoc=yes --pkgname nmap --pkgversion 7.31 \
     --fstrans=no --deldesc=yes --delspec=yes --default

Step 4:

On my system this shows:

andrew@athens:~$ nmap --version

Nmap version 7.31 ( https://nmap.org )
Platform: x86_64-unknown-linux-gnu
Compiled with: nmap-liblua-5.3.3 openssl-1.0.2g libpcre-8.38
               libpcap-1.7.4 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select
andrew@athens:~$ 

Hopefully this will also work well on your system :).


The configure script is asking for the location of the OpenSSL library headers and *.so files, not the openssl executable. On Ubuntu/Debian systems, you can install these headers by installing the libssl-dev package. If you install it this way, you do not have to provide the location to the configure script; it will find it on its own.

As another user pointed out, you can also run apt-get build-dep nmap to install all the prerequisites for building the nmap package, but this might be more than you want. Both will work.