How to install nmap on Ubuntu, Fedora and Linux Mint

Nmap is available in the official repositories of every major Linux distribution, so installing it almost always takes a single command. What changes from one distro to another is the package manager: apt on Debian, Ubuntu and derivatives like Linux Mint, dnf on Fedora and RHEL, pacman on Arch. This guide collects the right command for each, how to verify the installation worked, and how to run a first scan without hitting the most common mistakes first-time users make.

If you're also looking for the more advanced commands (port scanning, OS detection, NSE scripts), the full guide is Installing and using nmap on Linux: advanced scanning.

Table of contents

Ubuntu, Debian and Linux Mint (apt)

Ubuntu, Debian and the distributions built on them, including Linux Mint, Pop!_OS and Elementary OS, all use apt as their package manager. The command is identical on every one of them:

sudo apt update
sudo apt install nmap

The first command refreshes the list of packages available from the configured repositories; the second actually installs nmap. On Linux Mint there's no variation needed: since it's based on Ubuntu, it inherits the same package manager and the same base repositories.

On some minimal Debian installations, the sudo package might not be present. In that case, run the commands as root, without the sudo prefix:

apt update
apt install nmap

Fedora and RHEL/CentOS (dnf)

Fedora and the Red Hat family of distributions (RHEL, CentOS Stream, Rocky Linux, AlmaLinux) use dnf:

sudo dnf install nmap

Older versions of CentOS or RHEL may still use yum instead of dnf. The command works the same way:

sudo yum install nmap

There's no need to refresh the package list first, unlike with apt: dnf does that automatically before every installation.

Arch Linux and derivatives (pacman)

On Arch Linux, Manjaro and other Arch-based distributions, nmap is installed with pacman:

sudo pacman -S nmap

The -S (sync) flag installs the package by downloading it from the official repositories, automatically refreshing the local database if needed.

Verifying the installation

On every distribution, after installing it's worth checking that the binary is reachable and confirming the installed version:

nmap --version

The output shows the nmap version and the libraries it was compiled with (OpenSSL, libssh2, PCRE and others). If the command returns "command not found", the problem is almost always one of the two described in the Common problems section below.

Running your first test scan

Before running any scan, there's a rule that applies to any security testing tool: nmap should only be used against systems you own or have explicit authorization to test. Scanning networks or hosts belonging to someone else without permission can be a criminal offense, regardless of intent.

The simplest and safest test is a scan against yourself (localhost):

nmap localhost

This returns the list of open ports on your own machine, along with the service running on each one (SSH, a local web server, a listening database, and so on). It's a good way to confirm the installation works and to get a feel for the output format.

For a target specifically meant to be scanned, the nmap project maintains a public test host:

nmap scanme.nmap.org

scanme.nmap.org is maintained by the nmap developers themselves precisely so people can test the tool without needing additional authorization, with an implicit expectation of reasonable scan frequency and aggressiveness.

Common problems

"command not found" right after installing. On some distributions the package may not have correctly added the binary to the PATH, or the terminal is caching the command lookup from before the installation. Try opening a new terminal window, or force the shell to recompute its command cache:

hash -r

Insufficient permissions for some scan types. Some of nmap's scanning techniques, in particular the SYN scan (-sS), require root privileges because they construct raw network packets. Without sudo, nmap automatically falls back to a TCP connect scan (-sT), which works but is slower and more easily detected by a monitoring system.

sudo nmap -sS scanme.nmap.org

The package isn't in the default repositories. On some minimal distributions or very old releases, nmap might not be present in the default repositories. On Debian and derivatives, check that the main repository is enabled in /etc/apt/sources.list; on Fedora and RHEL, check that the EPEL repository is enabled if you're on an older release.

Resources