How to use Nmap

Hackbydoing Academy tool guide · Network scanning & recon · free, no login

What Nmap is, in plain words

Nmap scans a computer or network to find which numbered doors (ports) are open and what programs are answering behind them.

A working nmap command

nmap -sV 192.168.99.20

This checks the machine at 192.168.99.20 and reports its open ports plus the name and version of the program answering on each one.

Every piece of the command, explained

--min-rateThe next number is a speed floor: nmap sends at least that many scan packets per second, so a big scan finishes faster but is noisier.
--scriptThe next piece is the name of a small built-in check (an NSE script) to run against the target, such as http-title to grab a web page title.
--script-argsThe next piece gives extra settings to a script you picked with --script, written like name=value, for example a username or a file path the script needs.
--script=upnp-infoThis is --script with its value joined on by an equals sign: it runs the upnp-info check, which asks a router or gateway what it reveals about itself (maker, model, firmware) over UPnP, the auto-setup feature on port 1900.
--top-portsThe next number limits the scan to that many of the most commonly used ports, instead of the usual top 1000.
-AAggressive scan: turns on several checks at once — the operating system guess, version detection, the default scripts, and the route the packets take to reach the target.
-PnSkip the opening 'are you there?' check and treat every target as if it is switched on, useful when a machine blocks ping but is actually up.
-T0Timing template 0, the slowest and quietest speed: packets are sent far apart to stay unnoticed. Templates run from -T0 (slowest) to -T5 (fastest).
-T4Timing template 4, a fast speed for quick scans on a good network: thorough enough for labs, but loud and easy to spot in logs.
-iLThe next piece is the name of a text file listing the targets to scan, one per line, instead of typing them on the command line.
-oAThe next piece is a base filename, and nmap saves the results in all three of its file formats at once (normal text, XML, and an easy-to-search greppable file).
-oNThe next piece is a filename, and nmap saves the normal human-readable results into that file as well as showing them on screen.
-pThe next piece is the port or ports to check, such as 80, a list like 22,80,443, or a range like 1-1000. Without it, nmap checks the 1000 most common ports.
-p-Check every TCP port, all 65535 of them, not just the common ones. The dash after the p means 'the full range'.
-sCRun nmap's default set of small built-in checks (scripts) against the open ports — a safe, standard bundle that gathers extra details.
-sUScan UDP ports instead of the usual TCP ones. UDP is the 'send it and don't wait for an answer' style of traffic used by things like DNS and voice calls, and this scan is slower.
-sVVersion detection: after finding an open port, nmap talks to the program behind it to learn its name and version number.
-snDiscovery only: find which machines are switched on in a range, without checking any of their ports. This used to be called a ping scan.
targetThe address or name of the machine to scan, or a whole range written like 192.168.99.0/24, which means every address in that block.

Use it the legal way

Only run nmap on systems you own or have explicit, written permission to test — at work that means a signed engagement, at home that means your own lab. Inside Hackbydoing Academy you practice on simulated networks and lab machines built for exactly this, where breaking things is the lesson and no one else's systems are involved. Learning how a tool works also teaches you what it looks like from the defender's chair: the logs it leaves, the traffic it makes, and the settings that shut it down.

✦ Practice Nmap hands-on in a guided lab

Reading about nmap is step one. In the Academy you run it yourself, step by step, in guided labs on simulated networks — 185 rooms covering attack and defense, from your first scan to full operations, with a defender's debrief at the end of every room. Founding membership is $9.99/mo for the first 500 members.

Join Hackbydoing Academy →

Related tool guides

Free from the Hackbydoing Academy — learn cybersecurity by doing: real tools, guided labs, attack and defense, on simulated networks. More free material: Tool Guides index · Free Downloads Library · Hackbydoing Academy · Print this page (Ctrl/Cmd+P) for a clean paper copy.