How to Install Nmap on Ubuntu Linux
Learn how to check whether Nmap is installed, refresh Ubuntu package information, install Nmap with APT, and verify the installation from a terminal.
Nmap is a command-line network discovery and security-scanning tool. This lesson explains how to install it on Ubuntu, a Linux distribution that uses APT for software package management.
Some Ubuntu installations may already include Nmap, so check for it before installing anything. The commands in this lesson use Ubuntu's configured package repositories rather than untrusted third-party downloads.
Prerequisites
- Access to an Ubuntu system.
- Ability to open a terminal and enter commands in a shell, the command-line environment used to interact with Linux.
- An account authorized to use
sudofor administrative operations.
How Ubuntu Package Management Works
A Linux distribution is a packaged operating system built around the Linux kernel. Distributions can use different software-management tools and package formats, so installation instructions are not identical across Linux systems.
This lesson focuses specifically on Ubuntu and its APT-based package management. APT finds, downloads, and installs software packages from configured package repositories. The apt-get command is a command-line interface for performing APT operations.
A package repository is a trusted software source that provides packages and package metadata. APT may also install dependencies, which are additional packages required for an application to function.
Check Whether Nmap Is Already Installed
Open a terminal from Ubuntu's application menu, or use your desktop environment's terminal shortcut. At the shell prompt, run:
nmap --versionThe --version option asks the executable to display its version information without performing a scan.
| Goal | Command | Expected Result |
|---|---|---|
| Check for Nmap | nmap --version | Version details if Nmap is installed, or an unavailable-command message if it is absent |
Interpret the result
- If the command displays Nmap version information, Nmap is already available from the command line. You can skip installation and begin using it.
- If Ubuntu reports that Nmap is not installed or that the command cannot be found, continue with the installation steps.
Refresh Ubuntu Package Information
Before installing software, refresh the local package index. This index is local metadata that tells APT which package versions and dependencies are currently available from the configured repositories.
Run:
sudo apt-get updatesudo runs an administrative operation with elevated privileges. Refreshing package information does not upgrade installed software; it only downloads current package metadata. An upgrade is a separate operation that changes installed package versions.
APT may request your user password. While you type it, the terminal normally shows no characters or placeholder symbols. Enter the password and press Enter.
Install Nmap with APT
After the package index refresh completes, install the Ubuntu package named nmap:
sudo apt-get install nmapAPT examines the package and determines whether additional dependencies are needed. It may list Nmap, supporting libraries, or other packages that will be installed automatically.
| Output Item | Meaning |
|---|---|
| Package lists | APT is reading available package metadata. |
| Dependency tree | APT is calculating package relationships and required supporting packages. |
| Additional packages | Other packages selected automatically because Nmap requires them. |
| Download size | The amount of data APT needs to obtain from the repositories. |
| Disk-space usage | The estimated storage required after installation. |
| Confirmation prompt | APT is waiting for approval before making the changes. |
Review the package list, download amount, and disk-space estimate. If the changes are expected, type Y and press Enter when APT asks for confirmation. APT then downloads and installs Nmap and its required dependencies.
Verify the Installation
When installation finishes, run the version check again:
nmap --versionVersion output confirms that Nmap is installed and available from the command line. The exact version depends on the Ubuntu release and the package version provided by its configured repositories.
Complete Installation Workflow
- Open a terminal.
- Run
nmap --version. - If version information appears, Nmap is already installed.
- If the command is unavailable, run
sudo apt-get update. - Install Nmap with
sudo apt-get install nmap. - Review the packages, dependencies, download size, and disk-space estimate.
- Approve the confirmation prompt.
- Run
nmap --versionagain to verify the result.
Troubleshooting
Nmap is not installed or the command cannot be found
The executable is either not installed or is not available in the current command environment. Refresh package information, install the nmap package with APT, and repeat the version check.
APT asks for confirmation
This is normal. APT has calculated which packages will be installed, how much data must be downloaded, and how much disk space is needed. Review the changes and approve the prompt if they are expected.
Permission is denied
System-wide package installation requires administrator permission. Run the package command with sudo from an account authorized to use it. If the account is not permitted to use sudo, contact the Ubuntu system administrator.
APT has outdated package information
The local package index may not have been refreshed recently. Run:
sudo apt-get updateThen retry:
sudo apt-get install nmapWhat to Do Next
Now that Nmap is installed, learn more about what Nmap is or continue to start Nmap. For a broader reference, see the Nmap guide. If you use Windows instead of Ubuntu, see how to install Nmap on Windows.