sodcalculator

10 Tech How-To

How to Install Nmap on Ubuntu

Guide 10-41055 · Updated · Step by step

Installing Nmap on Ubuntu gives you a command-line tool for discovering hosts and checking which network ports respond. You’ll install it from Ubuntu’s package repositories, verify that it runs, and learn how to make a basic scan of a network or system you’re authorized to assess.

What You’ll Need

  • A computer running Ubuntu and an account with permission to use the terminal.
  • An internet connection to download the package.
  • Your account password if Ubuntu asks for administrator approval. The installation uses sudo, which runs a command with elevated privileges.
  • Permission to scan any computer or network you test. Scan only systems you own or are explicitly allowed to assess.

Step-by-Step

  1. Open a terminal. Press Ctrl+Alt+T, or open the Applications menu and search for Terminal. The commands below are entered in this window.
  2. Refresh Ubuntu’s package list. Run sudo apt update and press Enter. Type your password if prompted; the terminal does not show characters while you type, which is normal. This checks the configured software repositories for current package information. It does not upgrade every installed application.
  3. Install Nmap. Run sudo apt install nmap. Review the proposed changes and type Y if asked to confirm. Ubuntu downloads Nmap and any required dependencies, then installs them. If it says Nmap is already the newest version, it is already installed.
  4. Check that installation succeeded. Run nmap --version. The output should identify Nmap and show version and build information. You can also run command -v nmap; a successful result normally prints a path such as /usr/bin/nmap.
  5. Try a safe scan of your own computer. Run nmap 127.0.0.1. This checks the loopback address, which refers to the Ubuntu computer itself, rather than scanning an unrelated device. Nmap reports ports it can identify as open, closed, or filtered. No open ports is a valid result and does not mean installation failed.
  6. Scan an authorized target only when you have its address. For a device or network you own or have permission to test, use a command such as nmap 192.168.1.20, replacing the example address with the target’s actual IP address. For a basic scan of a small network you administer, a private range might look like nmap 192.168.1.0/24; confirm the correct range with your network settings before running it. A scan can generate network traffic and may be blocked or logged.
  7. Use administrator privileges only when needed. Some scan techniques need elevated privileges to access low-level network functions. If Nmap explains that a requested scan requires privileges, use sudo nmap followed by the specific options and authorized target. Do not run commands with sudo automatically: ordinary host scans generally do not require it.

Common Mistakes

  • Skipping sudo during installation: apt install needs administrator permission. Put sudo at the beginning of the installation command and enter your own Ubuntu password when prompted.
  • Using the wrong command: The package name and executable are both nmap. Enter sudo apt install nmap to install it, then nmap to run it.
  • Expecting a scan to list every device or service: Firewalls, routing, host settings, and network restrictions affect what Nmap can see. A port reported as filtered is not the same as a confirmed open port.
  • Confusing a private IP address with a public one: Addresses such as 192.168.x.x and 10.x.x.x are commonly used inside private networks. Make sure you have the intended target and authorization; do not guess at addresses or scan networks you do not control.
  • Copying example addresses literally: Replace an example IP or network range with the correct value for your setup. Scanning 127.0.0.1 checks only the local computer.

Tips

  • Use nmap --help for a quick list of options, or man nmap to read the manual. Press q to exit the manual viewer.
  • To check a particular port on an authorized device, use nmap -p 22 192.168.1.20, replacing both the port and address as appropriate. The -p option specifies the port to check.
  • Keep scans focused. Start with one known device and a basic scan before choosing more options. Avoid aggressive or high-volume scans on networks where you do not have clear permission.
  • Ubuntu’s APT repositories handle dependencies and updates. To install later updates available through your configured repositories, run sudo apt update and then sudo apt upgrade; review the proposed changes before confirming.

Troubleshooting

  • Unable to locate package nmap: Check your internet connection, then run sudo apt update and try sudo apt install nmap again. If the problem continues, check that Ubuntu’s software repositories are enabled in Software & Updates and that APT is not reporting repository errors.
  • APT reports a lock or another package operation is running: Another update or software installation may be in progress. Wait for it to finish and retry. Do not delete lock files or terminate package processes while they are working, as that can leave package management in an inconsistent state.
  • nmap: command not found after installation: Check the installation output for errors, then run sudo apt install nmap again. Try command -v nmap and open a new terminal if needed. If APT says it is installed but the command is still unavailable, inspect your shell’s PATH or ask an Ubuntu administrator to check the package installation.
  • A scan shows no hosts or ports: Confirm the target address and that your computer can reach it. A device may be offline, on a different network, or configured to block probes. Test only with an authorized target, and interpret “filtered” or “no response” as inconclusive rather than proof that a service is absent.
  • A scan says a technique needs privileges: Use sudo only for the specific scan that requires elevated access, and only against an authorized target. If you do not need that technique, use a basic scan without special options.

Frequently Asked Questions

Is Nmap free to install on Ubuntu?
Yes. Nmap is available in Ubuntu’s APT repositories and can be installed with sudo apt install nmap. Your Ubuntu installation should be able to reach its configured repositories.

Do I need to restart Ubuntu after installing Nmap?
No. Once APT finishes installing the package, you can run nmap in the terminal.

How do I check which Nmap version is installed?
Run nmap --version. It displays the installed version and additional build details.

Can I install Nmap without using the terminal?
Ubuntu’s graphical software tools may offer Nmap, depending on the repositories and Ubuntu setup. The terminal method is direct and makes it easy to verify the package and installation result.

Why does Nmap report a port as filtered?
A firewall, network device, or host may be preventing Nmap from determining whether the port is open or closed. Check the network path and target settings if you administer them; do not treat a filtered result as an open port.

Is it okay to scan any IP address?
No. Scan only your own systems or targets for which you have explicit permission. If you are unsure whether a device or network is in scope, get authorization before scanning.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →