# Host Discovery
Find live hosts before scanning ports. By default Nmap sends ARP (local), ICMP echo + TCP SYN 443 + TCP ACK 80 (remote).
nmap -sn 192.168.1.0/24
nmap -sn -PR 192.168.1.0/24
nmap -sn -PE -PP -PM TARGET
nmap -sn -PS22,80,443 -PA80,443 TARGET
nmap -sn -PU53,161 TARGET
nmap -Pn TARGET
nmap -sL 10.0.0.0/24
# Scan Types
Different TCP/UDP scan techniques. SYN scan is the default and most popular.
| Flag | Scan Type | When to use |
|---|---|---|
| -sS | TCP SYN (stealth) | Default, fast, doesn't complete handshake |
| -sT | TCP Connect | When you don't have raw socket privileges |
| -sU | UDP Scan | Discover DNS, SNMP, DHCP, TFTP services |
| -sA | TCP ACK | Map firewall rules (filtered vs unfiltered) |
| -sW | Window Scan | Like ACK but detects open ports on some systems |
| -sN | TCP Null | No flags set — evades some firewalls |
| -sF | FIN Scan | FIN flag only — stealthy against some IDS |
| -sX | Xmas Scan | FIN+PSH+URG — another firewall evasion technique |
| -sM | Maimon Scan | FIN+ACK — works on some BSD systems |
| -sI | Idle/Zombie Scan | Ultimate stealth — use a zombie host as proxy |
nmap -sS TARGET
nmap -sU --top-ports 200 TARGET
nmap -sS -sU -p T:1-1000,U:53,111,161,500 TARGET
nmap -sI zombie_ip TARGET
# Port Specification
Control exactly which ports to scan. By default Nmap scans the top 1000 ports.
nmap -p- TARGET
nmap -p 80,443,8080,8443 TARGET
nmap -p 1-1024 TARGET
nmap --top-ports 100 TARGET
nmap -p- --min-rate=1000 TARGET
nmap -p T:80,443,U:53,161 TARGET
# Service & Version Detection
Don't just find open ports — identify what's running and what version. Critical for finding exploits.
nmap -sV TARGET
nmap -sV --version-intensity 9 TARGET
nmap -sV --version-light TARGET
nmap -sC TARGET
nmap -sC -sV -p 22,80,443 TARGET
nmap -A TARGET
# OS Detection
Fingerprint the operating system by analyzing TCP/IP stack behavior.
nmap -O TARGET
nmap -O --osscan-guess TARGET
nmap -O --osscan-limit TARGET
# NSE Scripts
The Nmap Scripting Engine is incredibly powerful. 600+ scripts for vuln scanning, brute-force, enumeration, and more.
ls /usr/share/nmap/scripts/ | wc -lScript Categories
nmap --script=default TARGET
nmap --script=vuln TARGET
nmap --script=safe TARGET
nmap --script="vuln and safe" TARGET
Most Useful Scripts
nmap -p 445 --script=smb-enum-shares,smb-enum-users,smb-os-discovery TARGET
nmap -p 80,443 --script=http-enum,http-headers,http-methods,http-title TARGET
nmap -p 53 --script=dns-zone-transfer --script-args dns-zone-transfer.domain=DOMAIN TARGET
nmap -p 21 --script=ftp-anon,ftp-bounce,ftp-syst TARGET
nmap -p 25 --script=smtp-enum-users,smtp-open-relay TARGET
nmap -p 3306 --script=mysql-enum,mysql-info,mysql-empty-password TARGET
nmap -p 443 --script=ssl-enum-ciphers,ssl-cert,ssl-heartbleed TARGET
nmap --script=smb-vuln-ms17-010 -p 445 TARGET
Script Arguments
nmap --script=http-brute --script-args http-brute.path=/admin,userdb=users.txt,passdb=pass.txt -p 80 TARGET
nmap --script=http-put --script-args http-put.url=/uploads/shell.php,http-put.file=shell.php -p 80 TARGET
# Firewall & IDS Evasion
Techniques to bypass firewalls, IDS/IPS, and avoid detection during scans.
nmap -f TARGET
nmap --mtu 16 TARGET
nmap -D RND:10 TARGET
nmap -D decoy1,decoy2,decoy3,ME TARGET
nmap -S SPOOFED_IP -e eth0 -Pn TARGET
nmap -g 53 TARGET
nmap --data-length 25 TARGET
nmap --scan-delay 5s TARGET
nmap --badsum TARGET
# Timing & Performance
Control scan speed. T0-T1 for stealth, T3 is default, T4-T5 for speed.
| Flag | Template | Use case |
|---|---|---|
| -T0 | Paranoid | IDS evasion — 5 min between probes |
| -T1 | Sneaky | IDS evasion — 15 sec between probes |
| -T2 | Polite | Reduce bandwidth usage |
| -T3 | Normal | Default — balanced speed |
| -T4 | Aggressive | Fast scans on reliable networks |
| -T5 | Insane | Fastest — may miss ports on slow networks |
nmap -T4 --min-rate=1000 -p- TARGET
nmap --min-parallelism 100 TARGET
nmap --max-retries 1 TARGET
nmap --host-timeout 30s TARGET
# Output Formats
Save your results. Always use -oA to save all 3 formats at once.
nmap -oN scan.txt TARGET
nmap -oX scan.xml TARGET
nmap -oG scan.gnmap TARGET
nmap -oA scan TARGET
nmap -oG - TARGET | grep "open" | awk '{print $2}'
nmap -v --reason TARGET
# Real-World Combos
Copy-paste ready combinations for common pentesting scenarios.
Initial Recon (Pentest / OSCP)
nmap -p- --min-rate=1000 -T4 TARGET -oN allports.txt
nmap -p OPEN_PORTS -sC -sV -oA detailed TARGET
Web Server Audit
nmap -p 80,443,8080,8443 -sV --script="http-*" TARGET
Active Directory / Domain Controller
nmap -p 53,88,135,139,389,445,464,636,3268,3269 -sV -sC TARGET
Vulnerability Scan
nmap -sV --script=vuln -p OPEN_PORTS TARGET -oA vulnscan
Stealthy Scan
nmap -sS -T1 -f -D RND:5 -g 53 --data-length 25 TARGET
Network Sweep
nmap -sn 10.0.0.0/24 -oG - | grep "Up" | awk '{print $2}' > live_hosts.txt
nmap -iL live_hosts.txt -p- --min-rate=1000 -oA full_scan
Want all 11,600+ commands?
This Nmap cheatsheet is just one tool. Pentest Mindmap organizes 11,600+ commands across 32 categories — from recon to post-exploitation — with instant search and one-click copy.
Try free for 7 days →