Install Nmap on Ubuntu 20.04 - Step by Step Process ?

Nmap (Network Mapper) is used by Network administrators for security scanning and network discovery. It is a free tool mostly used for port scanning .

It works by sending raw IP packets and then listens for responses to determine which ports are open or closed. Network administrators use Nmap to identify hosts, OS, services, and vulnerabilities on your network.

Nmap scans for vulnerabilities on your network, performs inventory checks, and monitors host or service uptime, and so on.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to secure their Linux System.

In this context, we shall look into how to install Nmap on the Ubuntu system. 

How to install Nmap on Ubuntu ?

There are following three different ways to install Nmap on Ubuntu:

1. Installing Nmap on Ubuntu via apt.

2. Installation Nmap on Ubuntu via Snap.

3. Installation Nmap on Ubuntu via Source Code.

Note: Ensure that you are using a user with sudo or root privileges if you want to install Nmap on your Ubuntu system.

1. How to install Nmap on Ubuntu via apt ?

You can install Nmap on Ubuntu using the apt command.

Here are the installation steps:

i. Update repository index using this command:

$ sudo apt update

ii. Then install Nmap as follows:

$ sudo apt install nmap

Enter the sudo password and then you will be prompted to confirm if you want to proceed with the installation. 

To carry on, type y and after that press Enter.

The installation will take a while based on your internet speed. 

Once completed, you can use the below command to verify the installation and to check the version of Nmap:

$ nmap --version

2. How to install Nmap on Ubuntu via Snap ?

Nmap is also available as a snap package for Ubuntu OS. 

To install Nmap via snap, you first have to install snapd tool on your system. 

Here are the installation steps:

i. Use the below command to install snapd on your system:

$ sudo apt install snapd

Once snapd is installed, proceed to the next step.

ii. Install Nmap snap package using the below command in Terminal:

$ sudo snap install nmap

Nmap installation will start and, once completed.

You can also use the below command to check the version of Nmap on your system if you later need to do so:

$ nmap --version

3. How to install Nmap via Ubuntu Source Code ?

Nmap can be installed by downloading and compiling the source code. Use this procedure if you want to have the latest version of Nmap.

Here are the installation steps:

i. First, install the build-essential package. Issue the command below in Terminal to do so:

$ sudo apt install build-essential

This package contains the necessary packages required to compile source code.

ii. Visit Nmap official Downloads page and download Nmap latest version in tar.bz2 format or use the following command to download the currently available latest version 7.9.1:

$ wget https://nmap.org/dist/nmap-7.91.tar.bz2

iii. Extract the tar.bz2 archive using the below command in Terminal:

$ tar xf nmap-7.91.tar.bz2

iv. Navigate to the extracted directory using the cd command as follows:

$ cd nmap-7.91/

Then run the configure script to check if the system has all the prerequisites for installing the software. 

If it shows any error then you will have to go back and install the missing prerequisites:

$ sudo ./configure

v. Execute the make command to build Nmap software:

$ sudo make

vi. Now, install Nmap using the command below in Terminal:

$ sudo make install

Once Nmap is installed, you will see the following lines at the end of the output:


Now to verify the Nmap installation and to check the installed version, issue the below command in Terminal:

$ nmap --version

How to uninstall Nmap from Ubuntu ?

If you need to remove Nmap from the Ubuntu system, you can simply do so using the below command:

$ sudo apt remove nmap

To remove Nmap along with all the related configuration files, issue the below command instead:

$ sudo apt purge nmap

If you have installed Nmap through snap, you can remove it as follows:

$ sudo snap remove nmap

If you have installed Nmap from the source, you can remove it as follows:

$ cd nmap-7.91/
$ sudo make uninstall

[Need urgent assistance in fixing missing packages on Ubuntu systems? We are available. ]


This article covers different methods to install Nmap on Ubuntu. If you want to learn how to use nmap, visit our guide on 15 Mostly Used Nmap Commands for Scanning Remote Hosts .

Nmap works by sending data packets on a specific target (by IP) and by interpreting the incoming packets to determine what posts are open/closed, what services are running on the scanned system, whether firewalls or filters are set up and enabled, and finally what operating system is running.

To install Nmap on Ubuntu:

1. Make sure the software packages on your Ubuntu system are up-to-date with the command:

$ sudo apt-get update

2. To install NMAP on Ubuntu, run the command:

$ sudo apt-get install nmap

The system prompts you to confirm and continue by typing y and pressing Enter.

3. To verify the installation was successful and to determine the current version of Nmap:

$ nmap --version

More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com