The one downside to a tool as robust and powerful as Nmap is remembering so many commands. Even many seasoned industry professionals fail to make the most of Nmap simply because keeping track of all its flags can prove such a challenge.
We have compiled and organized this Nmap cheat sheet to help you master what is arguably the most useful tool in any penetration testerβs arsenal. Whether you use it to memorize Nmapβs options, as a quick reference to keep nearby, or as a study sheet for your CEH/Pentest+ exam, weβre certain it will help you become a Nmap pro.
Download your own copy of this cheat sheet here. Now, letβs get to the Nmap commands.
Nmap Cheat Sheet Search
Search our Nmap cheat sheet to find the right cheat for the term you're looking for. Simply enter the term in the search bar and you'll receive the matching cheats available.
TCP connect port scan (Default without root privilege)
-sU
nmap 192.168.1.1 -sU
UDP port scan
-sA
nmap 192.168.1.1 -sA
TCP ACK port scan
-sW
nmap 192.168.1.1 -sW
TCP Window port scan
-sM
nmap 192.168.1.1 -sM
TCP Maimon port scan
Host Discovery
SWITCH
EXAMPLE
DESCRIPTION
-sL
nmap 192.168.1.1-3 -sL
No Scan. List targets only
-sn
nmap 192.168.1.1/24 -sn
Disable port scanning. Host discovery only.
-Pn
nmap 192.168.1.1-5 -Pn
Disable host discovery. Port scan only.
-PS
nmap 192.168.1.1-5 -PS22-25,80
TCP SYN discovery on port x. Port 80 by default
-PA
nmap 192.168.1.1-5 -PA22-25,80
TCP ACK discovery on port x. Port 80 by default
-PU
nmap 192.168.1.1-5 -PU53
UDP discovery on port x. Port 40125 by default
-PR
nmap 192.168.1.1-1/24 -PR
ARP discovery on local network
-n
nmap 192.168.1.1 -n
Never do DNS resolution
Nmap Command Generator
Say goodbye to the hassle of trying to remember the exact syntax for your Nmap commands! With our Nmap Command Generator, you can simply say what you need Nmap to do and we will generate the command for you.
Port Specification
SWITCH
EXAMPLE
DESCRIPTION
-p
nmap 192.168.1.1 -p 21
Port scan for port x
-p
nmap 192.168.1.1 -p 21-100
Port range
-p
nmap 192.168.1.1 -p U:53,T:21-25,80
Port scan multiple TCP and UDP ports
-p
nmap 192.168.1.1 -p-
Port scan all ports
-p
nmap 192.168.1.1 -p http,https
Port scan from service name
-F
nmap 192.168.1.1 -F
Fast port scan (100 ports)
-top-ports
nmap 192.168.1.1 -top-ports 2000
Port scan the top x ports
-p-65535
nmap 192.168.1.1 -p-65535
Leaving off initial port in range makes the scan start at port 1
-p0-
nmap 192.168.1.1 -p0-
Leaving off end port in range makes the scan go through to port 65535
Service and Version Detection
SWITCH
EXAMPLE
DESCRIPTION
-sV
nmap 192.168.1.1 -sV
Attempts to determine the version of the service running on port
-sV -version-intensity
nmap 192.168.1.1 -sV -version-intensity 8
Intensity level 0 to 9. Higher number increases possibility of correctness
-sV -version-light
nmap 192.168.1.1 -sV -version-light
Enable light mode. Lower possibility of correctness. Faster
-sV -version-all
nmap 192.168.1.1 -sV -version-all
Enable intensity level 9. Higher possibility of correctness. Slower
-A
nmap 192.168.1.1 -A
Enables OS detection, version detection, script scanning, and traceroute
grep " open " results.nmap | sed -r βs/ +/ /gβ | sort | uniq -c | sort -rn | less
Reverse sorted list of how often ports turn up
Miscellaneous Nmap Flags
SWITCH
EXAMPLE
DESCRIPTION
-6
nmap -6 2607:f0d0:1002:51::4
Enable IPv6 scanning
-h
nmap -h
nmap help screen
Other Useful Nmap Commands
COMMAND
DESCRIPTION
nmap -iR 10 -PS22-25,80,113,1050,35000 -v -sn
Discovery only on ports x, no port scan
nmap 192.168.1.1-1/24 -PR -sn -vv
Arp discovery only on local network, no port scan
nmap -iR 10 -sn -traceroute
Traceroute to random targets, no port scan
nmap 192.168.1.1-50 -sL -dns-server 192.168.1.1
Query the Internal DNS for hosts, list targets only
nmap 192.168.1.1 --packet-trace
Show the details of the packets that are sent and received during a scan and capture the traffic.
You are only doing yourself a disservice by failing to learn and utilize all of Nmapβs features. It is the first go-to tool you will use in the scanning and enumeration stage of many assessments, setting the foundation for the rest of your pentest.
Keep a copy of this Nmap cheat sheet to refer back to, and consider our Complete Nmap Ethical Hacking Course. It, and many other ethical hacking courses, are available in our VIP Memberβs Section.
Frequently Asked Questions
What is Nmap, and why is it used?
Nmap is a free network scanning tool used to discover hosts and services on a network by analyzing responses to various packets and requests.
What is the Nmap command used for?
Penetration testers and network administrators will use Nmap to discover machines on a network and their open ports, running services, operating systems, and a wealth of other useful information.
Is Nmap scanning legal?
This depends on your jurisdiction. In many places, the answer is no, not without prior permission from the owner of the site or network.
Nmap is a tool used for scanning and enumeration. Hackers and penetration testers use the information gathered to see what the available attack surface is.
However, there are a great number of NSE scripts that can perform such actions as password brute forcing, checking for backup and configuration files, searching for remote file inclusion (RFI) vulnerabilities, and testing default credentials.
How do I scan an IP with Nmap?
A basic scan of a single IP address is as easy as: nmap <ip>
This will return if the host is up and responding to ping, what ports are open, and what services are running on them. More complex commands can be found in the cheat sheet above.
Is it OK to Nmap Google?
The long answer is, it depends on your jurisdiction. The short answer is, probably not and you shouldnβt do it. Even if it isnβt illegal where you live, it will most certainly violate Googleβs terms of service.
Do firewalls block Nmap?
Firewalls can block access to ports, which would indeed block Nmap. Nmap does have flags to attempt to evade firewalls and intrusion detection systems, which we have listed in the cheat sheet above.
Is Nmap a vulnerability?
After you have installed Nmap on your host system, an over-ambitious antivirus program may flag it as malicious. So long as you have downloaded it from the official Nmap website, it is safe to have installed.
Can Nmap bypass a firewall?
Nmap has several optional services which can attempt to bypass firewalls and spoof its scans. See the Firewall / IDS Evasion and Spoofing section above for details.
Can Nmap hack WiFi?
Nmap has many NSE scripts designed to brute force different services and logins. Depending on the login portal, there may be a relevant script to do so.Β
More realistically, Nmap would be used to enumerate the network, and one of many free programs better suited to WiFi hacking would be used afterward.
Can Nmap crack passwords?
Nmap has many brute force scripts which will automate password login attempts on various services, such as MySQL, Telenet, and POP3. This may provide a quick win, but password attacks are better handled by tools dedicated to that purpose, such as THC Hydra.
How do I read Nmap results?
Fortunately, even the more complex Nmap scans display their results in a clear and easy-to-follow manner. You also have the ability to output the data in various forms, including as an XML or grepable file (see the Output section for details).
You can also see our Zenmap vs. Nmap article to learn about the graphical version of the tool.
Nathan House is the founder and CEO of StationX. He has over 25 years of experience in cyber security, where he has advised some of the largest companies in the world. Nathan is the author of the popular "The Complete Cyber Security Course", which has been taken by over half a million students in 195 countries. He is the winner of the AI "Cyber Security Educator of the Year 2020" award and finalist for Influencer of the year 2022.
THANK YOU!!! I used to use Legion but for some reason the frontend is proving unreliable, so I need to put on my big boy pants and use Nmap the proper way.
Thank you! It’s content like this that helps make the membership cost worth it. Don’t get me wrong, the sheer content on the website makes it worth the cost but this stuff is just icing on the cake!
Mike QAAssuming an attacker runs the following command on nmap: βnmap βA βT3 βS 192.168.1.2 βp- 192.168.1.6β. What does the attacker try to achieve? says:
Please log in again.
The login page will open in a new tab. After logging in you can close it and return to this page.
StationX Accelerator Pro
Enter your name and email below, and we’ll swiftly get you all the exciting details about our exclusive StationX Accelerator Pro Program. Stay tuned for more!
StationX Accelerator Premium
Enter your name and email below, and we’ll swiftly get you all the exciting details about our exclusive StationX Accelerator Premium Program. Stay tuned for more!
StationX Master's Program
Enter your name and email below, and we’ll swiftly get you all the exciting details about our exclusive StationX Master’s Program. Stay tuned for more!
THANK YOU!!! I used to use Legion but for some reason the frontend is proving unreliable, so I need to put on my big boy pants and use Nmap the proper way.
Thanks
Thank you! It’s content like this that helps make the membership cost worth it. Don’t get me wrong, the sheer content on the website makes it worth the cost but this stuff is just icing on the cake!
nmap βA βT3 βS 192.168.1.2 βp- 192.168.1.6
Thanks a ton. It is very useful.
Solved problem
jsjs
Very good informations, Thanks a lot.
Thanks you