Ubuntu

How to Install Nmap on Ubuntu 20.04

Install Nmap on Ubuntu

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.

This guide is about how to install Nmap on the Ubuntu system. There are following three different ways to install Nmap on Ubuntu:

  • Installing Nmap on Ubuntu via apt
  • Installation Nmap on Ubuntu via Snap
  • Installation Nmap on Ubuntu via Source Code

Note: The installation procedures shown here have been tested on Ubuntu 20.04 LTS system. You should have sudo or root privileges if you want to install Nmap on your Ubuntu system.

Installing Nmap on Ubuntu via apt

You can install Nmap on Ubuntu using the apt command. Here are the installation steps:

1. Update repository index using this command:

$ sudo apt update

2. 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.

installing Nmap via apt

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

The following output verifies that Nmap version 7.80 has been installed on our system.

Nmap version

Installing 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:

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

$ sudo apt install snapd

Once snapd is installed, proceed to the next step.

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

$ sudo snap install nmap

Nmap installation will start and, once completed, the following output will be displayed: Installing Nmap on Ubuntu via Snap

The above output shows Nmap version 7.91 has been successfully installed on our machine.

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

Installing 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:

1. 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.

2. 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

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

$ tar xf nmap-7.91.tar.bz2

4. 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

If the configuration is successful, you will see the following view on your Terminal.

5. Issue the make command to build Nmap software.

$ sudo make

6. 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

Remove Nmap

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

There is always more than one method to do a task in Linux. Here, we have shown you three different methods to install Nmap on Ubuntu. If you want to learn how to use nmap, visit our post on 15 Mostly Used Nmap Commands for Scanning Remote Hosts.

Similar Posts