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 cheat sheet: the commands you will use most
| Command | What it does |
|---|---|
nmap 192.168.1.10 | Scan the 1,000 most common TCP ports of one host |
nmap -sn 192.168.1.0/24 | Host discovery only: which devices are online (no port scan) |
nmap -p 22,80,443 target | Scan specific ports |
nmap -p- target | Scan all 65,535 TCP ports |
nmap -F target | Fast scan of the 100 most common ports |
nmap -sV target | Detect the service and version on each open port |
nmap -O target | Guess the operating system (needs admin rights) |
nmap -A target | Aggressive: OS, versions, default scripts and traceroute |
nmap -sU -p 53,161 target | Scan UDP ports |
nmap -T4 target | Faster timing (T0 slowest to T5 fastest) |
nmap -oN scan.txt target | Save 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
-T4speeds up scans on reliable networks;-T2or lower is gentler.-vshows progress as the scan runs.-oN file.txt,-oX file.xmlor-oA namesave the results.-Pnskips 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.
- In the US, unauthorized access to computers is covered by the Computer Fraud and Abuse Act.
- In the UK, the Computer Misuse Act 1990 applies.
- Even when a scan isn’t illegal, it can break your internet provider’s terms or a company’s policy.
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
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.
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.
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.
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.
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).
-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.
