Chat with us, powered by LiveChat

Nmap Cheat Sheet 2026: The Complete Command Reference

Nmap Cheat Sheet 2026: The Complete Command Reference

Nmap (Network Mapper) is a free, open-source tool for network discovery, port scanning, and security auditing. This nmap cheat sheet covers every command, flag, and scan type you need, from basic host discovery to advanced firewall evasion.

Use it as a quick reference during penetration tests, network audits, or CTF challenges.

TL;DR

  • Nmap scans networks to find live hosts, open ports, running services, and operating systems.
  • The most common command is nmap -sV -sC -O -p- <target> for a full service and OS scan.
  • SYN scan (-sS) is the default and fastest scan type for most users with root/admin privileges.
  • NSE scripts (-sC or –script) extend Nmap with vulnerability checks, brute-forcing, and enumeration.
  • Always get written authorization before scanning any system you don’t own.

Most Useful Nmap Commands (90% real-world scanning)

TaskCommand
Quick default scannmap <target>
Ping sweep (host discovery)nmap -sn 192.168.1.0/24
Stealth SYN scannmap -sS <target>
TCP connect scan (no root)nmap -sT <target>
Scan specific portsnmap -p 22,80,443 <target>
Scan all 65,535 portsnmap -p- <target>
Fast scan (top 100 ports)nmap -F <target>
Detect service versionsnmap -sV <target>
Detect operating systemnmap -O <target>
Run default NSE scriptsnmap -sC <target>
Aggressive all-in-one scannmap -A <target>
Faster timing templatenmap -T4 <target>
IPv6 scannmap -6 <target>
Save output in all formatsnmap -oA results <target>

Before running any of the commands in this cheat sheet, it is strongly recommended to practice in a controlled environment. Here’s a complete guide on how to set up a penetration testing lab so you can safely test Nmap techniques.

What Is Nmap?

Nmap is a command-line tool that discovers devices on a network and identifies the services those devices are running. Security teams use it for vulnerability assessments, network inventory, and penetration testing.

It works by sending crafted packets to target hosts and analyzing the responses it gets back.

Core capabilities:

  • Host discovery: find live devices on a network
  • Port scanning: find open, closed, and filtered ports
  • Service and version detection
  • Operating system fingerprinting
  • Scriptable interaction via the Nmap Scripting Engine (NSE)

Target Specification

Nmap accepts single IPs, ranges, subnets, hostnames, and target list files as scan targets.

SyntaxExampleDescription
Single IPnmap 192.168.1.10One host
Hostnamenmap example.comResolves DNS first
IP rangenmap 192.168.1.1-50Range of last octet
CIDR blocknmap 192.168.1.0/24Entire subnet
Multiple targetsnmap 192.168.1.1 192.168.1.5Space-separated
Target list from filenmap -iL targets.txtOne target per line
Exclude hostsnmap 192.168.1.0/24 –exclude 192.168.1.1Skip specific hosts
Random targetsnmap -iR 10Scan 10 random public IPs (use with caution)

Host Discovery

Host discovery finds which devices are online before Nmap scans any ports, which saves time on large networks.

FlagPurposeWhen to Use
-snPing scan only, no port scanFast inventory of live hosts
-PnSkip host discovery, treat all as upTarget blocks ping/ICMP
-PS<ports>TCP SYN discoveryBypassing ICMP-blocking firewalls
-PA<ports>TCP ACK discoveryEvading stateless firewalls
-PU<ports>UDP discoveryDetecting UDP-only hosts
-PEICMP echo discoveryStandard internal network ping
-nDisable DNS resolutionSpeed up large scans
-RForce DNS resolutionConfirm hostnames

Example — find all live hosts on a /24 subnet without touching any ports:

nmap -sn 10.0.0.0/24

Scan Types (With When-to-Use Notes)

A scan type tells Nmap which kind of packet to send to determine whether a port is open, closed, or filtered. The mechanics of each technique are documented in the official Port Scanning Techniques guide. 

FlagScan TypeWhen to Use
-sSTCP SYN scanDefault choice — fast, stealthy, requires root
-sTTCP Connect scanNo root access available
-sUUDP scanChecking DNS, SNMP, DHCP services
-sAACK scanMapping firewall rule sets
-sWWindow scanAdvanced firewall analysis
-sNNull scanFirewall/IDS evasion testing
-sFFIN scanStealth evasion against older firewalls
-sXXmas scanEvasion, unusual flag combination
-sOIP protocol scanIdentify supported protocols (TCP, UDP, ICMP)
-sYSCTP INIT scanTesting SCTP-based services (telecom)

Practical rule: Use -sS for most scans. Reach for -sU only when UDP services matter, and use Null/FIN/Xmas scans only in controlled evasion testing.

Port Specification

Port specification flags control exactly which ports Nmap checks, which directly affects scan speed and accuracy. See the official Port Specification and Scan Order guide for advanced syntax. 

CommandResult
-p 80Scan port 80 only
-p 22,80,443Scan specific ports
-p 1-1000Scan a port range
-p-Scan all 65,535 ports
-p U:53,T:80Mix UDP and TCP ports
-FFast scan — top 100 ports
–top-ports 20Scan the 20 most common ports
-rScan ports sequentially, not randomized

Service & OS Detection

Service and OS detection identify the exact software version and operating system running on a target, which is essential for finding known vulnerabilities. Nmap’s official docs cover Service and Version Detection and OS Detection in full depth. 

FlagPurpose
-sVDetect service/version on open ports
–version-intensity 9Maximum detection accuracy (slower)
-ODetect operating system
–osscan-guessGuess OS aggressively when uncertain
-ACombines -sV, -O, -sC, and traceroute

Example — reveal both service banners and likely OS in one pass:

nmap -sV -O 192.168.1.1

Timing & Performance

Timing templates control how fast Nmap scans, trading speed against stealth, higher numbers scan faster but are easier for firewalls and IDS systems to detect. The official Timing and Performance guide covers every tunable option. 

TemplateFlagUse Case
Paranoid-T0Maximum stealth, IDS evasion
Sneaky-T1Slow, low-detection scans
Polite-T2Reduces bandwidth/target load
Normal-T3Default speed
Aggressive-T4Fast, recommended for most pentests
Insane-T5Fastest, high chance of inaccurate results

Other performance flags:

  • –min-rate 1000 — sends packets no slower than 1000/sec
  • –max-retries 2 — limits retransmissions on unresponsive ports
  • –host-timeout 30m — skips slow/unresponsive hosts after 30 minutes

Output Formats

Nmap can save scan results as plain text, XML, or grepable output, so results can be reused in reports or fed into other tools. Full format specs are in the official Output guide. 

FlagFormatUse Case
-oN file.txtNormal textHuman-readable report
-oX file.xmlXMLImport into other tools
-oG file.gnmapGrepableScripting and parsing
-oA basenameAll formats at onceSaves .nmap, .xml, .gnmap together
-v / -vvVerbose / extra verboseLive scan progress
-dDebug outputTroubleshooting scan issues

See also: Wireshark Cheat Sheet: Complete Filters, Shortcuts & Commands (2026)

NSE Scripts (Most Useful Ones)

The Nmap Scripting Engine (NSE) runs Lua scripts that automate vulnerability detection, enumeration, and brute-forcing directly during a scan. NSE scripts are grouped into categories — such as vuln, auth, brute, discovery, and safe — so you can target exactly the kind of check you need. Browse every available script in the official NSEDoc Reference Portal. 

CommandPurpose
-sCRun default safe scripts
–script vulnCheck for known vulnerabilities
–script safeRun only non-intrusive scripts
–script authTest for authentication bypass issues
–script bruteAttempt credential brute-forcing
–script discoveryGather extra host/service info
–script http-titleGrab webpage titles
–script smb-os-discoveryIdentify Windows OS via SMB
–script ftp-anonTest for anonymous FTP login
–script ssl-heartbleedCheck for Heartbleed vulnerability
–script dns-bruteBrute-force subdomains via DNS
–script-args user=admin,pass=passPass custom arguments to scripts
–script-updatedbUpdate the NSE script database

Scripts can be combined and scoped to a specific port for faster, targeted checks.

Example — check a single host for the Heartbleed bug:

nmap -p 443 --script ssl-heartbleed <target>

Example — run multiple script categories at once:

nmap -sV --script "vuln,safe" -p 80,443 <target>

Keep NSE current with nmap –script-updatedb since new vulnerability scripts are added as CVEs are disclosed — this matters most for 2026 engagements, where recently published scripts often cover the latest known flaws.

For a practical shortlist of the most useful scripts in real engagements, see this focused guide on the top 10 NSE scripts every penetration tester should know.

Firewall & IDS Evasion

Firewall and IDS evasion flags manipulate packet structure and timing to test whether security controls detect or block a scan. Use these only during authorized penetration tests to validate detection controls, never against systems without permission.

FlagTechniqueWhen to Use
-fFragment packetsBypass simple packet filters
-D RND:10Decoy scan with 10 random IPsObscure the real scanning source
-S <spoofed-IP>Spoof source IPTesting IP-based access controls
-g 53Use a specific source port (e.g., DNS)Bypass port-based firewall rules
–data-length 25Append random data to packetsAvoid signature-based detection
–mtu 8Set custom packet sizeFragment evasion
-e eth0Specify network interfaceMulti-homed systems

Example — combine fragmentation with a decoy scan for evasion testing:

nmap -f -D RND:10 -sS <target>

Recommended Scan Sequences for Real Engagements

A structured scan sequence from host discovery to vulnerability checks — produces faster, more accurate results than running one large scan at once. These steps build on the official Nmap Usage Examples. 

Recommended Scan Sequences for Real Engagements

1. Initial Reconnaissance

nmap -sn 192.168.1.0/24

Find all live hosts before deeper scanning.

2. Fast Port Sweep

nmap -F -T4 <target>

Quickly identify common open ports.

3. Full Port Scan

nmap -p- -T4 <target>

Confirm no ports were missed.

4. Deep Service Enumeration

nmap -sV -sC -O -p <open-ports> <target>

Gather service versions, OS, and default script results on confirmed open ports.

5. Vulnerability Scan

nmap --script vuln -p <open-ports> <target>

Check discovered services against known CVEs.

Once you have identified potential vulnerabilities with Nmap, the next logical step is exploitation. A detailed overview of the most widely used exploitation frameworks can help you move from discovery to controlled testing efficiently.

6. Report and Save

nmap -oA final_scan <target>

Store results in all formats for the final report.

Modern Tips (IPv6, Cloud & Containers)

Modern Nmap usage increasingly involves IPv6 networks, cloud infrastructure, and containerized services, each with its own scanning considerations.

IPv6 scanning: Use -6 to scan IPv6 addresses; combine with -sS -6 for stealth SYN scans over IPv6:
nmap -6 -sS <IPv6-target>

  • Cloud environments: Many cloud providers (AWS, Azure, GCP) block unsolicited scans by default and may flag or suspend accounts that trigger them — always confirm scanning is permitted under your provider’s acceptable use policy and, where required, file a scan-authorization request first.
  • Containers: Scan container networks directly by targeting the container’s internal IP; –top-ports is useful for quickly checking exposed microservice ports without a full sweep.
  • Kubernetes/orchestrated environments: Combine -sn with a CIDR scan of the pod network range to inventory live pods before targeted port scans, since IPs are often reassigned dynamically.
  • Rate-limiting awareness: Cloud security groups and WAFs increasingly auto-block aggressive scans — use -T2 or -T3 and –max-retries in cloud contexts to avoid triggering lockouts.
  • Script freshness: Run nmap –script-updatedb before major 2026 engagements so NSE checks reflect the most recently disclosed vulnerabilities.
  • Version awareness: Always confirm you’re running a current Nmap release (nmap -V) since IPv6, NSE, and detection accuracy all improve with newer builds.

Download Free PDF – Nmap Cheat Sheet 2026 PDF

Frequently Asked Questions

What is Nmap used for?

Nmap is used to discover live hosts on a network, scan for open ports, identify running services, and detect operating systems for security auditing and network management.

Is Nmap legal to use?

Nmap is legal to use on networks and systems you own or have explicit written permission to test. Scanning systems without authorization is illegal in most countries.

What is the difference between -sS and -sT scans?

-sS (SYN scan) is faster and stealthier but requires root/administrator privileges. -sT (Connect scan) completes the full TCP handshake and works without elevated privileges.

How do I scan all ports with Nmap?

Run nmap -p- <target> to scan all 65,535 TCP ports on a target.

What does the -A flag do in Nmap?

The -A flag enables OS detection, version detection, script scanning, and traceroute in a single command.

How do I make Nmap scans faster?

Use a higher timing template (-T4), limit the port range with -p, and increase the packet rate with –min-rate.

What is NSE in Nmap?

NSE (Nmap Scripting Engine) is a framework that runs Lua scripts to automate tasks like vulnerability detection, brute-forcing, and service enumeration.

Can Nmap detect firewalls?

Yes. An ACK scan (-sA) helps map firewall rule sets by identifying which ports are filtered versus unfiltered.

How do I scan for a specific vulnerability with Nmap?

Run an NSE vulnerability script, for example nmap –script ssl-heartbleed -p 443 <target>, to check for a specific known flaw.

Does Nmap work on Windows, macOS, and Linux?

Yes. Nmap is cross-platform and available for Windows, macOS, and all major Linux distributions.

What is the fastest Nmap scan command?

nmap -F -T4 <target> scans the top 100 ports quickly using an aggressive timing template.

How do I save Nmap results to a file?

Use -oN file.txt for a text report, -oX file.xml for XML, or -oA basename to save all formats at once.

If you prefer a more permanent practice environment, this guide shows how to build a home penetration lab that you can use for ongoing Nmap practice and full engagement simulations.

Disclaimer

Nmap is a powerful network scanning tool that must only be used on systems and networks you own or have explicit, written authorization to test. Unauthorized scanning of networks, servers, or devices you do not control may violate laws such as the Computer Fraud and Abuse Act (U.S.), the Computer Misuse Act (U.K.), and equivalent legislation in other countries.

This article is provided for educational and authorized security testing purposes only. Dumpsgate is not responsible for misuse of the information contained in this cheat sheet.

Share: Facebook LinkedIn X
C Cade Miller

Cade Miller is an active Cybersecurity Consultant and technical contributor at Dumpsgate, specializing in cloud security architecture, identity and access management (IAM), and proactive threat detection. Moving beyond theoretical security concepts, Cade draws directly from his ongoing fieldwork and Security Operations (SecOps) experience to deliver highly actionable, research-backed insights. Dedicated to continuous hands-on testing, he regularly evaluates emerging defensive technologies and pursues advanced industry certifications, translating his firsthand experience into battle-tested exam strategies and practical security blueprints for IT professionals.

GDPR