Nmap is an open source and free tool for network discovery, security auditing, and vulnerability scanning. It is usually used by administrators and security officers to map network connections, identify open ports, and determine running services.
To install nmap on your system network, you need to fully understand the key features.
Key Features of Nmap:
- Host Discovery
- Port Scanning
- Service and Version Detection
- Operating System Detection
- Scriptable Interaction
Prerequisites to Install Nmap
Before you install nmap, make sure that your system is fully prepped by following these prerequisites.
- System Requirements
Nmap is a generally lightweight tool that runs on different operating systems, including Linux, Windows, and macOS.
Linux:
- A Linux distribution such as Ubuntu, Debian, CentOS, or Arch Linux
- At least 50 MB of free disk space
- Minimum 512MB RAM (1GB recommended)
Windows:
- Windows 7, 8, 10, 11, or Windows Server
- At least 100MB of free disk space
- Administrator privileges for installation
macOS:
- macOS 10.14 (Mojave) or later
- Homebrew installed (recommended for easy installation)
- Installing Dependencies
Before moving on to install nmap, you need to install some dependencies:
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
For Linux:
Most of the dependencies comes pre-installed, but if you’re compiling Nmap from source, install the following:
sudo apt update && sudo apt install build-essential libssl-dev
For RHEL-based systems:
sudo dnf install gcc make openssl-devel
For Windows:
No additional packages are required since all the dependencies are pre-installed.
For macOS (Using Homebrew):
Ensure Homebrew is installed, then update it:
brew update
Installing Nmap on Linux
Nmap is available in the official repositories of most Linux distributions. You can install it using package managers or compile it from source.
- Install Nmap on Ubuntu/Debian
On Ubuntu and Debian-based distributions, install Nmap using apt:
sudo apt update

sudo apt install nmap -y
apt install nmap
snap isntall nmap
To verify the installation, run the following command:
nmap –version
- Install Nmap on CentOS/RHEL
For RHEL distributions, (CentOS, AlmaLinux, Rocky Linux), install Nmap using dnf or yum:
For RHEL 8+ and CentOS Stream:
sudo dnf install nmap -y
For older CentOS versions:
sudo yum install nmap -y
To verify the installation, run the following command:
nmap –version
- Install Nmap on Arch Linux
On Arch-based distributions, install Nmap using pacman:
sudo pacman -S nmap
To verify the installation, run the following command:
nmap –version
Installing Nmap on Windows
Nmap comes with a graphical user interface (Zenmap) along with the command-line tool. To install Nmap on Windows, follow these steps:
- Downloading and Installing Nmap on Windows
- Visit the Nmap download page and download the latest Windows installer in an .exe file.
- Run the installer by double clicking the download option and follow the on-screen instructions.
- Choose the installation options if you want to change the default ones.
- Click on install and wait for the process to complete.
- Tap on finish to exit the installer.
- Verifying the Installation
Verify that the installation was successful by running the following prompt:
Open Command Prompt or PowerShell
Press Win + R, type cmd, and hit Enter.
Check Nmap Version
Run the following command:
nmap –version
If installed correctly, you should see output like:
Nmap version 7.x ( https://nmap.org )
Installing Nmap on macOS
To install Nmap on macOS, follow these steps:
- Using Homebrew to Install Nmap (Recommended Method)
Homebrew is the easiest way to install Nmap on macOS. Use the following command to install homebrew:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
Then, install Nmap with:
brew install nmap
To run the installation, run:
nmap –version
- Alternative Installation Methods
Manual Installation from the Official Site:
- Download Nmap for macOS.
- Install Nmap by opening the download .dmp file and follow prompts.
- Verify installation by running nmap –version
Compiling Nmap from Source (Advanced Users):
If you need the latest development version, compile Nmap from source:
git clone https://github.com/nmap/nmap.git
cd nmap
./configure
make
sudo make install
Verify installation by:
nmap –version
Verifying Nmap Installation
After you install Nmap, confirm if it works accurately by running a basic scan.
- Running Nmap from the Command Line
Open terminal and run the command prompt:
nmap
If Nmap is installed, you will see the usage instructions displayed.
- Checking the Installed Version
To verify the installed version of Nmap, use the following command:
nmap –version
This confirms that Nmap is correctly installed and ready to use.
Additional Verification (Optional):
To ensure Nmap is working as expected, run a simple localhost scan:
nmap 127.0.0.1
If Nmap returns results about open ports and services, it’s fully operational.
Basic Nmap Commands to Get Started
Task | Command | Description |
Scanning a Single Host | nmap 192.168.1.1 | Scans a single target IP or domain to check for live status and open ports. |
Scanning Multiple Hosts | nmap 192.168.1.1 192.168.1.2 | Scans multiple specific IP addresses. |
nmap 192.168.1.1-10 | Scans a range of IPs (from 192.168.1.1 to 192.168.1.10). | |
nmap -iL targets.txt | Scans multiple hosts listed in a file (targets.txt). | |
Detecting Open Ports | nmap -p 80,443 192.168.1.1 | Scans for specific open ports (80 and 443) on a target. |
nmap -p- 192.168.1.1 | Scans all 65,535 ports on a target. | |
nmap –top-ports 10 192.168.1.1 | Scans the 10 most commonly used ports |
Uninstalling Nmap
If you are no longer using Nmap, you can uninstall it from the system using the right commands for your operating system.
- Removing Nmap from Linux
To remove Nmap from Linux:
On Ubuntu/Debian:
sudo apt remove –purge nmap -y
sudo apt autoremove -y
On Arch Linux:
sudo pacman -R nmap
To verify uninstallation:
nmap –version
If the command returns “command not found,” Nmap has been successfully removed.
- Uninstalling Nmap from Windows and macOS
To uninstall Nmap from Windows or macOS, follow these steps:
On Windows:
- Open control panel > programs and features > find Nmap > uninstall.
- Follow the prompts to complete uninstallation.
- Verify uninstallation by running nmap –version
If the command is not recognized, Nmap has been uninstalled.
On macOS (Using Homebrew):
If you installed Nmap via Homebrew, uninstall it with:
brew uninstall nmap
If you installed it manually via a .dmg file, move the Nmap application to Trash and remove any leftover files from /usr/local/bin/nmap if necessary.
Conclusion
This guide is an easy walk through of how to install Nmap in your system for optimal network management and security. The steps are fairly short and limited and even with limited technical knowledge, you can easily do so!
Frequently Asked Questions
1. Can I run Nmap without installing it?
Yes, you can use Nmap as a portable tool on Windows by running the executable from the extracted folder. On Linux/macOS, you can compile and run it from the source without system-wide installation.
2. Can I install Nmap without root or administrator privileges?
On Linux/macOS, you need root (sudo
) privileges for installation. However, you can download and compile Nmap from the source without root access. On Windows, administrative rights are required for installation.
3. Can I install Nmap inside a Docker container?
Yes, you can use an Nmap Docker container:docker run --rm -it instrumentisto/nmap