This article provides a comprehensive reference guide to Nmap commands, flags, and scan types for penetration testers and security professionals. It covers syntax, all major scanning methodologies, service detection, timing options, NSE scripting, output formats, and firewall evasion techniques, with commands tested against current Nmap 7.95. The guide emphasizes authorised use only and provides six professional scan sequences used in real penetration testing engagements.
Key insights
Scan type determines visibility to defensesThe article explains that scan type fundamentally determines how Nmap probes target ports and therefore how visible the scan is to IDS systems and firewalls. SYN scans (-sS) are the default, fastest, and most stealthy but require root; TCP connect scans (-sT) complete the full handshake and are more visible but don't require root. NULL, FIN, and Xmas scans can bypass older stateless firewalls but are unreliable on modern systems. Understanding this distinction is critical because it directly affects which scan type to use in different testing scenarios.
Service and OS detection maps to CVEsService version detection (-sV) identifies exact software versions running on open ports, which directly maps to known CVEs and vulnerability databases. OS detection (-O) fingerprints the target operating system. The article demonstrates that combining these two flags transforms a simple port list into a vulnerability assessment surface. For example, the article shows how Apache 2.4.54 can then be searched in a CVE database for known vulnerabilities.
Six-step professional reconnaissance workflowThe article provides six specific scan sequences used in actual penetration testing engagements, executed in order: (1) rapid host discovery using ICMP variants, (2) quick triage with SYN scan and top 1000 ports, (3) complete baseline with all ports and default scripts, (4) vulnerability scanning on open ports found previously, (5) UDP key services (DNS, SNMP, NTP, NetBIOS, IKE, OpenVPN), and (6) web surface enumeration with HTTP-specific scripts. This sequence constitutes a complete initial reconnaissance on any authorised target.
NSE scripts extend scanning to vulnerability assessmentThe Nmap Scripting Engine provides 600+ bundled scripts that transform Nmap from a port scanner into a vulnerability platform. Script categories include default (-sC), vulnerability detection (--script vuln), authentication bypass (--script auth), brute force (--script brute), and specific checks like EternalBlue detection (--script smb-vuln-ms17-010). Scripts are located in /usr/share/nmap/scripts/ on Kali Linux and can be searched by keyword.
Timing templates balance speed and accuracyThe article presents timing options from T0 (Paranoid, 5 minutes per port for IDS evasion) through T5 (Insane, very fast but may miss ports on slow targets). T3 is the default, T4 provides aggressive speed suitable for fast networks with approximately 4x speed boost, and fine-grained control is available through --min-rate (packets per second) and --max-retries flags. The tradeoff is that faster scans may miss ports on slow or heavily filtered networks.
Output formats enable integration and reportingNmap supports multiple output formats: -oN for normal text, -oX for XML (imports into Metasploit), -oG for grepable format (compatible with grep piping), and -oA to save all formats simultaneously. The grepable format is specifically demonstrated for parsing — extracting IPs with open ports using grep and awk. This flexibility allows scan results to be integrated into vulnerability management platforms and penetration testing reports.
Firewall evasion techniques probe filter behaviorThe article describes methods for authorised targets in filtered environments: packet fragmentation (-f with 8-byte or 16-byte fragments), decoy scanning (-D to send from multiple spoofed IPs), source port spoofing (--source-port 53 to appear as DNS traffic), and IDS threshold evasion through scan delays (--scan-delay 1s). The --badsum flag sends packets with incorrect checksums specifically to probe firewall responses without triggering full inspection.
Authorised use is a legal and ethical requirementThe article explicitly and repeatedly emphasizes that all commands must be run only on systems you own, have explicit written authorisation to scan, or on legal practice platforms like TryHackMe and Hack The Box. It states scanning any system without permission violates computer misuse laws in most jurisdictions regardless of intent, making authorisation a fundamental prerequisite rather than an optional consideration.
Bottom line: Master the six-step professional scan sequence (host discovery, quick triage, complete baseline, vulnerability scan, UDP services, web surface) and run them as habits on authorised targets; the difference between amateur and professional reconnaissance is thoroughness and consistency in applying these methodologies, not individual technical knowledge. Always verify explicit written authorisation before scanning any system, as unauthorised scanning violates computer misuse laws.
🔐
Authorised Use Only: All Nmap commands on this page are for use on systems you own or have explicit written authorisation to scan. Use your home network, a VirtualBox lab, TryHackMe, or Hack The Box. Scanning systems without permission is illegal. Set up a legal home lab →
N
Nmap is the first tool every penetration tester opens. It is the first tool mentioned in every OSCP course, every ethical hacking curriculum, and every bug bounty reconnaissance guide. It has been actively developed since 1997 and is used by security professionals, system administrators, and researchers in every organisation that takes network security seriously. And the reference articles ranking at the top of Google for “Nmap commands with examples” were last updated in 2020.
This is the 2026 version — every command tested on current Kali Linux, every flag verified against the current Nmap 7.95 documentation, every example drawn from real authorised testing workflows. Every scan type. Every timing option. Every output format. Every NSE script category. And a free PDF at the end you can keep on your second monitor.
📥 Free Nmap Cheat Sheet PDF
Every command on this page, printer-ready, branded, no email required.
Nmap accepts targets in multiple formats. Understanding these first means you can scope any scan precisely — single hosts, ranges, CIDR blocks, or input files from a recon tool like Subfinder.
$nmaptarget.com# Domain name (resolves to IP first)
$nmap-iLtargets.txt# Read targets from file (one per line)
$nmap–exclude192.168.1.5192.168.1.0/24# Exclude specific host from range
$nmap-62001:db8::1# IPv6 target scan
NMap Scan Types — Every -s Flag Explained
The scan type determines how Nmap probes target ports — the TCP mechanism used, whether the full handshake completes, and therefore how visible the scan is to IDS systems and firewalls. This is the most important flag category to understand.
securityelites.com
NMAP SCAN TYPES — COMPARISON REFERENCE 2026
Flag
Name
Root?
Stealth
-sS
SYN Scan (half-open) DEFAULT
Yes
High
-sT
TCP Connect (full handshake)
No
Low
-sU
UDP Scan
Yes
Medium
-sN
NULL Scan (no flags set)
Yes
Very High
-sF
FIN Scan
Yes
Very High
-sX
Xmas Scan (FIN+PSH+URG flags)
Yes
Very High
-sn
Ping Sweep (no port scan — host discovery only)
No
N/A
Root = requires sudo/root privileges. Stealth = how likely to be logged by IDS/firewall. All scans require authorisation.
Nmap Scan Types — -sS (SYN) is the default and most widely used — fast, stealthy, requires root. -sT is used when root is unavailable. -sU covers UDP services (DNS, SNMP, NTP). NULL/FIN/Xmas scans bypass some older stateless firewalls but are unreliable on modern systems.
SCAN TYPE COMMANDS WITH REAL EXAMPLES
# SYN scan (default, requires root) — fastest and most common
$sudo nmap-sS192.168.1.1
# TCP connect (no root needed, more visible)
$nmap-sT192.168.1.1
# UDP scan — slow but essential (DNS, SNMP, NTP are UDP)
$sudo nmap-sU –top-ports100192.168.1.1
# Ping sweep — find all live hosts in a subnet (no port scan)
# Treat host as up even if not responding to ping (-Pn)
$nmap-Pn -sT192.168.1.1# Useful when ICMP is blocked
Port Specification — Targeting Exactly What You Need
PORT SPECIFICATION FLAGS
$nmap-p80192.168.1.1# Single port
$nmap-p80,443,8080192.168.1.1# Multiple specific ports
$nmap-p1-1024192.168.1.1# Port range 1 to 1024
$nmap-p-192.168.1.1# ALL 65535 ports (thorough but slow)
$nmap–top-ports100192.168.1.1# Top 100 most common ports
$nmap–top-ports1000192.168.1.1# Top 1000 (default without -p)
$nmap-pU:53,T:80192.168.1.1# UDP port 53 + TCP port 80
$nmap-F192.168.1.1# Fast scan — top 100 ports only
$nmap-r192.168.1.1# Scan ports in consecutive order
Service & OS Detection — What Is Actually Running
Knowing a port is open is only the start. Service version detection identifies the exact software and version running — which maps directly to known CVEs. OS detection fingerprints the target operating system. These two flags together are what transforms a port list into a vulnerability assessment surface.
SERVICE VERSION & OS DETECTION
$nmap-sV192.168.1.1# Service version detection
$nmap-sV –version-intensity9192.168.1.1# Max intensity (0-9)
$sudo nmap-O192.168.1.1# OS detection (requires root)
$sudo nmap-O –osscan-guess192.168.1.1# Aggressive OS guess if uncertain
$nmap-T2192.168.1.1# Polite — slows down to avoid congestion
$nmap-T3192.168.1.1# Normal — default timing (no flag = T3)
$nmap-T4192.168.1.1# Aggressive — fast networks, ~4x speed boost ← USE THIS
$nmap-T5192.168.1.1# Insane — very fast, may miss ports on slow targets
# Fine-grained timing control:
$nmap–min-rate5000192.168.1.1# Min 5000 packets/sec
$nmap–max-retries1192.168.1.1# Retry failed probes max 1 time (default: 3)
$nmap–host-timeout30s192.168.1.0/24# Skip host if no response in 30s
NSE Scripts — Nmap’s Superpower
The Nmap Scripting Engine transforms Nmap from a port scanner into a vulnerability assessment platform. 600+ scripts bundled with Kali Linux cover everything from service banner grabbing to vulnerability detection to brute force authentication testing.
NSE SCRIPT COMMANDS
$nmap-sC192.168.1.1# Run default scripts (equivalent to –script=default)
$nmap–scriptvuln192.168.1.1# All vulnerability detection scripts
$nmap–scriptdns-brutetarget.com# DNS subdomain brute force
# List all scripts matching a keyword:
$ ls /usr/share/nmap/scripts/ | grephttp# All HTTP-related scripts
$nmap–script-helphttp-title# Documentation for specific script
Output Formats — Save and Share Your Results
OUTPUT FLAGS
$nmap-oNscan.txt192.168.1.1# Normal output → text file
$nmap-oXscan.xml192.168.1.1# XML output (imports into Metasploit, etc.)
$nmap-oGscan.gnmap192.168.1.1# Grepable format (pipe through grep easily)
$nmap-oAscan_results192.168.1.1# ALL formats simultaneously ← USE THIS
$nmap-v192.168.1.1# Verbose output (show results as discovered)
$nmap-vv192.168.1.1# Very verbose
$nmap-d192.168.1.1# Debug output
$nmap–reason192.168.1.1# Show why each port has its state
# Parse grepable output for open ports:
$grep“open” scan.gnmap | awk‘{print $2}’# Extract IPs with open ports
Firewall Evasion & Spoofing Techniques
In authorised penetration tests, firewalls and IDS systems may filter or block standard scans. These flags allow you to probe for filter rules, fragment packets, and adjust scan behaviour to get more accurate results from filtered environments. All for authorised use on in-scope targets only.
FIREWALL EVASION FLAGS (AUTHORISED TARGETS ONLY)
$nmap-f192.168.1.1# Fragment packets (8-byte fragments)
$nmap-f -f192.168.1.1# 16-byte fragments (smaller = harder to reassemble)
$nmap–mtu24192.168.1.1# Custom MTU offset (must be multiple of 8)
$nmap–source-port53192.168.1.1# Spoof source port (firewalls allow port 53)
$nmap–data-length25192.168.1.1# Append random data to packets
$nmap–badsum192.168.1.1# Send packets with bad checksums (probe firewalls)
$nmap–scan-delay1s192.168.1.1# 1 second between probes (IDS threshold evasion)
Professional Scan Combinations — Copy-Paste Ready
These are the actual Nmap command combinations used in professional penetration testing engagements. Each serves a specific purpose — from fast initial triage to comprehensive vulnerability baseline. Run these on your home lab or authorised targets.
✓ These 6 scans constitute a complete initial reconnaissance on any authorised target
Professional Nmap Scan Sequences — These six scans are used in real penetration testing engagements. Run them in order on any authorised target: (1) host discovery, (2) quick triage, (3) complete baseline, (4) vuln scan on open ports, (5) UDP key services, (6) web surface. Save all output with -oA for the engagement report.
-oN Normal text -oX XML -oG Grepable -oA ALL formats ←USE -v Verbose
PRO COMBO
sudo nmap -sV -sC -O -p- -T4 -oA results [TARGET]
📥 Full PDF: securityelites.com/nmap-commands-cheat-sheet.pdf
Nmap Quick Reference Card 2026 — Screenshot this card for your second monitor or desktop wallpaper. Every category you will use daily: scan types, port specification, detection, timing, output formats, and the professional combo command. PDF version available at the link.
Nmap is Day 1. There Are 179 More Tools.
Master Every Kali Linux Tool — One Per Day. All Free.
The 180-Day Kali Linux Course covers Nmap in complete depth on Day 1 — and then one new tool every day for 179 more days. Every course article follows the same standard as this reference page.
Frequently Asked Questions — Nmap Commands with Examples
What is the most useful Nmap command for beginners?
nmap -sV -sC -p- -T4 [target] — service version detection, default scripts, all ports, fast timing. This is the comprehensive baseline scan professionals run on every authorised engagement.
What is the difference between nmap -sS and nmap -sT?
-sS is a SYN scan (half-open, requires root, stealthy, fast — preferred for pentesters). -sT is a TCP connect scan (no root needed, completes full handshake, more likely to be logged). Use -sS when running as root; use -sT when root is unavailable or -sS is filtered.
How do I make Nmap faster?
Use -T4 timing, –min-rate 5000, –max-retries 1, and scan specific ports rather than all 65535 when you know what you’re targeting. Note: faster scans may miss ports on slow or heavily filtered networks.
What is an NSE script?
NSE (Nmap Scripting Engine) scripts extend Nmap with 600+ Lua scripts for vulnerability detection, service enumeration, authentication testing, and more. Use -sC for default scripts, –script vuln for vulnerability detection, or –script [name] for specific scripts. Located at /usr/share/nmap/scripts/ on Kali Linux.
Is Nmap scanning legal?
Legal on systems you own or have explicit written authorisation to scan — your home network, VMs you control, authorised pentest targets, TryHackMe, Hack The Box. Scanning any system without permission is illegal under computer misuse laws in most jurisdictions, regardless of intent.
Nmap is not just a tool — it is a methodology. The difference between an amateur running nmap target and a professional running a full baseline scan with version detection, scripts, OS fingerprinting, and saved output is not technical knowledge. It is the habit of thoroughness. The commands in this article are the habits. Build them by running them in your home lab until they are automatic. The full Nmap deep-dive tutorial is Kali Linux Day 1.
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.