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
- Open a terminal. Press
Ctrl+Alt+T, or open the Applications menu and search for Terminal. The commands below are entered in this window. - Refresh Ubuntu’s package list. Run
sudo apt updateand 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. - Install Nmap. Run
sudo apt install nmap. Review the proposed changes and typeYif 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. - Check that installation succeeded. Run
nmap --version. The output should identify Nmap and show version and build information. You can also runcommand -v nmap; a successful result normally prints a path such as/usr/bin/nmap. - 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. - 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 likenmap 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. - 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 nmapfollowed by the specific options and authorized target. Do not run commands withsudoautomatically: ordinary host scans generally do not require it.
Common Mistakes
- Skipping
sudoduring installation:apt installneeds administrator permission. Putsudoat 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. Entersudo apt install nmapto install it, thennmapto 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.xand10.x.x.xare 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.1checks only the local computer.
Tips
- Use
nmap --helpfor a quick list of options, orman nmapto read the manual. Pressqto 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-poption 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 updateand thensudo apt upgrade; review the proposed changes before confirming.
Troubleshooting
Unable to locate package nmap: Check your internet connection, then runsudo apt updateand trysudo apt install nmapagain. 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 foundafter installation: Check the installation output for errors, then runsudo apt install nmapagain. Trycommand -v nmapand open a new terminal if needed. If APT says it is installed but the command is still unavailable, inspect your shell’sPATHor 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
sudoonly 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
- Clone a Hard Drive That Won’t Boot: Full Guide
- Destiny 2 Connection Error Codes: Step-by-Step Fix
- Fix Discord Picking Up Game Audio on Windows
- How to Sign in to Third-Party Apps with Your Apple ID
- Phone Link Not Working? Fix Android & iPhone Issues
- Gboard Not Working on iPhone? 8 Fixes That Actually Work