Install Nmap on Linux

NmapNmapBeginner
Practice Now

Introduction

In this lab, you will learn how to install Nmap, a powerful network scanning tool, on a Linux system. You will start by updating the package list using sudo apt update. Then, you will install Nmap with sudo apt install nmap and verify the installation by running basic commands to check functionality and version information.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL nmap(("Nmap")) -.-> nmap/NmapGroup(["Nmap"]) nmap/NmapGroup -.-> nmap/installation("Installation and Setup") nmap/NmapGroup -.-> nmap/host_discovery("Host Discovery Techniques") nmap/NmapGroup -.-> nmap/verbosity("Verbosity Levels") subgraph Lab Skills nmap/installation -.-> lab-530181{{"Install Nmap on Linux"}} nmap/host_discovery -.-> lab-530181{{"Install Nmap on Linux"}} nmap/verbosity -.-> lab-530181{{"Install Nmap on Linux"}} end

Update package list with sudo apt update

Before installing any new software on Linux, it is important to update the package list. The package list contains information about available software packages and their versions that can be installed on your system.

This step ensures that you have access to the latest versions of software packages and their dependencies. Think of it as refreshing a catalog before shopping so you know what items are currently available.

Open your Xfce terminal by clicking on the terminal icon in the dock or by navigating to the Applications menu and selecting Terminal. Once the terminal opens, type the following command:

sudo apt update

This command uses sudo to run with administrative privileges, which is required for system-wide updates. The apt update command connects to the configured software repositories and downloads information about available packages.

You will see output similar to the following:

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
...
Fetched 5,234 kB in 3s (1,745 kB/s)
Reading package lists... Done
Building dependency tree... Done
All packages are up to date.

The output shows the repositories being contacted and the package information being downloaded. When you see "Reading package lists... Done", it means the update has completed successfully.

Install Nmap with sudo apt install nmap

Now that our package list is updated, we can install Nmap. Nmap (Network Mapper) is an open-source utility used for network discovery and security auditing. Network administrators and security professionals use it to scan networks, discover hosts and services, and identify potential security vulnerabilities.

To install Nmap, type the following command in your terminal:

sudo apt install nmap

After entering the command, you will be prompted to confirm the installation. The system will display information about the packages that will be installed, including Nmap and any dependencies it requires. You will see a confirmation prompt that looks like this:

Reading package lists... Done
Building dependency tree... Done
The following additional packages will be installed:
  [list of dependencies]
Do you want to continue? [Y/n]

Type y and press Enter to confirm the installation.

The system will download and install Nmap and its dependencies. You will see output similar to this:

Getting packages: 100%
Preparing to unpack .../nmap_7.80+dfsg1-2build1_amd64.deb ...
Unpacking nmap (7.80+dfsg1-2build1) ...
Setting up nmap (7.80+dfsg1-2build1) ...
Processing triggers for man-db (2.10.2-1) ...

When the installation is complete, you will be returned to the command prompt. This indicates that Nmap has been successfully installed on your system.

Verify Nmap installation with nmap -v

After installing software, it is important to verify that the installation was successful. We can verify that Nmap is correctly installed by running it with the verbose option.

In your terminal, enter the following command:

nmap -v

The -v flag stands for "verbose," which tells Nmap to provide more detailed output about what it is doing. This is useful for verifying that Nmap is functioning correctly.

When you run this command, Nmap will perform a simple scan of your localhost (your own computer). You should see output similar to this:

Starting Nmap 7.80 ( https://nmap.org )
NSE: Loaded 151 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 12:34
Completed NSE at 12:34, 0.00s elapsed
Initiating Ping Scan at 12:34
Scanning localhost (127.0.0.1) [2 ports]
Completed Ping Scan at 12:34, 0.00s elapsed (1 total hosts)
Initiating Connect Scan at 12:34
Scanning localhost (127.0.0.1) [1000 ports]
Completed Connect Scan at 12:34, 0.10s elapsed (1000 total ports)
NSE: Script Post-scanning.
Initiating NSE at 12:34
Completed NSE at 12:34, 0.00s elapsed
Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds

The output confirms that Nmap is installed and running correctly. The first line displays the Nmap version (7.80 in this example), followed by details about the scan being performed.

If you see this output, it means Nmap has been successfully installed and is functioning properly.

Check installed version with nmap --version

To specifically check which version of Nmap is installed on your system, you can use the --version flag. This command provides a concise output with version information without performing any network scanning.

In your terminal, enter the following command:

nmap --version

This command will display detailed information about the installed version of Nmap. You should see output similar to this:

Nmap version 7.80 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
Compiled with: liblua-5.3.3 openssl-1.1.1f nmap-libssh2-1.8.0 libz-1.2.11 libpcre-8.39 libpcap-1.9.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

The output provides the following information:

  • The version number of Nmap (7.80 in this example)
  • The platform Nmap is running on
  • Libraries and features that were included when Nmap was compiled
  • Libraries and features that were not included
  • Available nsock engines (networking mechanisms that Nmap can use)

This information is useful for documentation purposes and for ensuring compatibility with specific features or scripts that may require a minimum version of Nmap.

Summary