Nmap Commands: Cheat Sheet With Examples (2026)

This Nmap commands cheat sheet covers the scans you will actually use: finding devices, checking open ports, detecting services and versions, and saving results. Every command follows the official Nmap reference guide.

Only scan networks you own or have written permission to test. The legal section below explains why.

Nmap commands cheat sheet with examples for network scanning

Nmap cheat sheet: the commands you will use most

CommandWhat it does
nmap 192.168.1.10Scan the 1,000 most common TCP ports of one host
nmap -sn 192.168.1.0/24Host discovery only: which devices are online (no port scan)
nmap -p 22,80,443 targetScan specific ports
nmap -p- targetScan all 65,535 TCP ports
nmap -F targetFast scan of the 100 most common ports
nmap -sV targetDetect the service and version on each open port
nmap -O targetGuess the operating system (needs admin rights)
nmap -A targetAggressive: OS, versions, default scripts and traceroute
nmap -sU -p 53,161 targetScan UDP ports
nmap -T4 targetFaster timing (T0 slowest to T5 fastest)
nmap -oN scan.txt targetSave results to a text file (-oX for XML, -oA for all formats)

Basic Nmap commands

Scan a single host

nmap scanme.nmap.org checks the 1,000 most common TCP ports. scanme.nmap.org is a host the Nmap project runs so you can practice legally.

Find devices on your network

nmap -sn 192.168.1.0/24 lists the devices that answer on your home network without scanning their ports. It’s a quick way to spot unknown devices on your Wi-Fi.

Port scanning commands

  • nmap -p 80 target: one port.
  • nmap -p 1-1000 target: a range.
  • nmap -p- target: every TCP port. Slow but thorough.
  • nmap --top-ports 20 target: the 20 most common ports.
  • nmap -sU target: UDP ports, much slower than TCP.

Nmap scan types: -sS vs -sT

-sS (SYN scan) is the default when you run Nmap with admin rights: fast and it never completes the connection. -sT (connect scan) is used without admin rights; it is slower and more visible in logs.

Service, version and OS detection

  • nmap -sV target: which program and version listens on each port (for example, OpenSSH 9.x).
  • nmap -O target: operating system guess.
  • nmap -A target: OS and version detection, default scripts and traceroute in one go.
  • nmap -sC target: run the default Nmap Scripting Engine (NSE) scripts.

Speed and output

  • -T4 speeds up scans on reliable networks; -T2 or lower is gentler.
  • -v shows progress as the scan runs.
  • -oN file.txt, -oX file.xml or -oA name save the results.
  • -Pn skips host discovery when a firewall blocks ping, treating the host as online.

Is Nmap legal?

Nmap itself is legal and free to download. What matters is what you scan. The Nmap project’s own legal guide recommends scanning only with permission.

Safe places to practice: your own network, virtual machines, and scanme.nmap.org.

Related free tools

Found an IP address you don’t recognize? Check who owns it with our free IP lookup. Securing your home network? See how to find and change your Wi-Fi password, and our list of best free OSINT tools.

Frequently asked questions

What is Nmap used for?

Nmap (Network Mapper) is a free, open-source tool to discover devices on a network, find which ports are open and identify the services and operating systems running on them. Network admins and security teams use it to audit their own networks.

What are the most useful Nmap commands?

For everyday use: nmap -sn 192.168.1.0/24 to find devices, nmap -sV target to identify services, nmap -p- target to scan every port, and nmap -A target for a detailed scan.

Is it legal to use Nmap?

Scanning your own network, or one you have written permission to test, is legal. Scanning other people’s systems without permission can break computer misuse laws and the rules of your internet provider.

Where can I practice Nmap legally?

Use your own home network or virtual machines, or scanme.nmap.org, a host the Nmap project set up so people can test scans against it.

Why does Nmap need sudo or administrator rights?

The default SYN scan (-sS) and OS detection (-O) build raw network packets, which requires root on Linux and macOS or administrator rights on Windows. Without them Nmap falls back to a slower connect scan (-sT).

What is the difference between -sS and -sT?

-sS is a SYN (“half-open”) scan: fast and the default with admin rights. -sT completes the full TCP connection: it works without special rights but is slower and easier to log.

Sources: Nmap reference guide · Nmap: legal issues · US DOJ: computer fraud · UK Computer Misuse Act 1990.

Related Posts