My Top 5 Nmap Commands You Need to Know
In this article, I’m sharing five Nmap commands that every system administrator, security engineer, or pentester should have in their toolbox.
Nmap (Network Mapper) is arguably the best-known and most widely used network mapping tool. Included in the repositories of all major Linux distributions, available on Windows and macOS, it has been part of IT teams’ daily work since its creation in 1998. If you’ve only ever used it for a simple nmap <ip>, you’re missing out on a lot of details and options! This tool is packed with features that let you do much more than a simple port scan, and using it without truly mastering it can create a false sense of security.
Warning: some of the techniques presented in this article may behave offensively on targeted systems. Make sure you have all the necessary authorizations before auditing an information system. Any unauthorized use is punishable under the Penal Code (Chapter III: Offenses Against Automated Data Processing Systems).
These five commands are taken from the book "Master Nmap - Network Mapping and Vulnerability Scanning", which I wrote and published through IT-Connect. If you want to go much further—TCP scan types, advanced NSE scripts, XML output handling, integration with Metasploit or Python—this book will give you a solid, step-by-step foundation.

Let’s get started with my top 5 Nmap commands to know!
Command No. 1 - Host Discovery: map a network without making noise
The first thing you do on an unknown network is find out which hosts are alive. The natural reflex is to send a simple ICMP ping to each address. The problem is that many firewalls filter ICMP packets, so you could conclude that a host is down when it is actually reachable over other protocols.
By default, when you run nmap 192.168.1.0/24, Nmap does perform host discovery, but then it immediately follows up with a scan of the 1000 most common ports on each active host. That behavior generates a significant amount of traffic and can take time on large networks. If your only goal is to get a list of active machines, there’s a more efficient way.
# Advanced network discovery without port scanning
nmap -sn -PP -PS22,3389,445,139 -PA80 192.168.1.0/24Let’s break down the options used in this command:
-sn: completely disables port scanning. Nmap is limited to the host discovery phase.-PP: enables ICMP Echo requests (the classic ping).-PS22,3389,445,139: sends a TCP SYN packet to those ports for each host. If the port responds (even with a RST), the host is considered up. Ports 22 (SSH), 3389 (RDP), 445 (SMB), and 139 (NetBIOS) are among the most commonly exposed in mixed Windows/Linux environments.-PA80: sends a TCP ACK packet to port 80. A firewall may respond to an ACK even without an HTTP service, which reveals the presence of an active device.
The result is a list of active hosts, obtained by combining several techniques, which is far more reliable than a simple ping scan alone.
Note : if you want to preview exactly which IP addresses will be targeted by a scan, without sending a single packet, you can add the -sL -n option. Nmap will display the list of targets and stop there. Very useful before running a scan on a sensitive environment to make sure you’ve got it right.
Command No. 2 - Advanced Service Discovery: versions and operating system
By default, Nmap identifies services by consulting its local database (/etc/services) to match a port number to a service name. So an open TCP/22 port will always be displayed as "ssh"… even if you’ve placed another service there. In environments that do not use standard ports, this behavior can make you miss important information.
That’s where the -sV option comes in, which tells Nmap to send probes, specific queries, to each open port in order to precisely identify the service, its technology, and its version. This technique, called banner grabbing, relies on the fact that most services display their name and version in their first response or respond in a certain way to specially formatted packets. Nmap can even send specially malformed packets to trigger a response from a given technology.
# Version and operating system detection on all ports
nmap -sV -O -p- 192.168.1.19Again, here is the breakdown of the options used:
-sV: enables service version detection.-O: enables operating system detection. Nmap analyzes subtle details in ICMP, TCP, and UDP packets to infer the target’s network stack and OS (Linux, Windows, etc.). This option requires root privileges.-p-: scans all 65,535 TCP ports, not just the 1000 most common ones. Essential if you don’t want to miss an unusual service exposed on a non-standard port.
Be careful, version detection increases scan time. On a large network, consider combining this command with -T4 (scan acceleration, which we’ll see in command No. 5) and restricting the target ports if you already have an idea of the services present.
At the end of this scan, you’ll get information such as Apache httpd 2.4.25 (Debian) or OpenSSH 8.9p1, allowing you to cross-reference these versions with known CVEs and quickly identify unmaintained services.
Command No. 3 - NSE Scripts on SMB: audit Windows configuration and vulnerabilities
One of Nmap’s greatest strengths is its script engine: NSE (Nmap Scripting Engine). It is a set of modules written in Lua that extend Nmap’s capabilities far beyond simple port scanning. There are more than 600 of them, divided into several categories: vuln (known vulnerability detection), discovery (advanced enumeration), auth (anonymous or brute-force authentication), safe, intrusive, and more.
The SMB service (TCP port 445) is one of the most interesting to use, especially in Windows environments. It often exposes critical configuration information, and some of its versions are associated with major vulnerabilities, including the famous EternalBlue (CVE-2017-0144), notably exploited by the WannaCry ransomware.
# SMB audit: security configuration and EternalBlue detection
nmap --script "smb-security-mode,smb2-security-mode,smb-vuln-ms17-010" -p 445 192.168.1.0/24The scripts used:
smb-security-mode: retrieves configuration information from SMBv1, including whether SMB exchange signing (SMB signing) is enabled or not. Lack of signing makes an SMB Relay attack possible, a technique frequently used in penetration testing to take control of accounts without knowing their password.smb2-security-mode: does the same for SMBv2 and SMBv3. This is often where IT teams forget to configure signing, thinking they have secured SMBv1 only.smb-vuln-ms17-010: checks whether the host is vulnerable to EternalBlue, one of the most exploited vulnerabilities of the last decade. This script belongs to the vuln category: it detects the vulnerability without exploiting it.
A typical result looks like this:
445/tcp open microsoft-ds
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb-vuln-ms17-010:
| VULNERABLE:
| Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)If you see message_signing: disabled, that’s a remediation item to escalate immediately. If you see VULNERABLE for ms17-010, you need to patch as soon as possible.
To go further on securing Windows environments and detecting Active Directory weaknesses, I invite you to check out our articles on BloodHound and Snaffler on IT-Connect.
Command No. 4 - NSE Scripts on HTTP: vulnerabilities and security headers
Web services (HTTP/HTTPS) are exposed on virtually every modern information system. Nmap provides a set of NSE scripts to audit them: known vulnerability detection, security header checks, directory enumeration, page title retrieval, and more.
The challenge is not to run just any script without thinking. Some scripts in the intrusive category can trigger errors on fragile services, or even cause crashes. The best practice is to combine categories to precisely control what will be executed, and of course, to know how to use nmap properly.
# HTTP audit: filtered vulnerabilities, without overly aggressive scripts
nmap --script "(http and vuln) and not intrusive and not dos" -p 80,443 192.168.1.19The script selection logic:
http and vuln: we target scripts that apply to the HTTP protocol and that belong to the vuln category (known vulnerability detection). This excludes brute-force scripts, aggressive enumeration, and so on.not intrusive and not dos: we explicitly exclude scripts considered too risky for service stability or likely to generate a denial of service.
This combination is a good compromise for a production audit: you identify known vulnerabilities (injections, directory traversal, bad configurations) without risking service instability.
If you want to go further on a specific web service, you can complement this with targeted scripts:
# Retrieve HTTP security headers and the page title
nmap --script "http-security-headers,http-title" -p 80,443 192.168.1.19Headers such as Strict-Transport-Security, X-Frame-Options, or Content-Security-Policy are quick indicators of a web application’s security maturity. Their absence is a common configuration flaw, easy to fix and often listed in audit reports.
For deeper web security audits (injection testing, JavaScript code analysis, parameter fuzzing), I’d point you to our dedicated articles on BurpSuite and Nuclei on IT-Connect. Nmap remains an excellent starting point, but it does not replace a specialized application security tool.
Command No. 5 - The full combo: a realistic scan for auditing or pentesting
So far, we’ve looked at targeted commands, each serving a specific purpose. In real-world auditing, the goal is to combine these options to get the maximum amount of information in the minimum amount of time. That’s what the following command does, and it’s almost always found in the early phases of a pentest or a network mapping exercise.
# Full scan: versions + default scripts + performance + multi-format export
nmap -sV -sC -T4 --top-ports 1024 -oA scan_réseau 192.168.1.0/24Here’s the breakdown of the options used, some of which we’ve already seen:
-sV: service version detection (seen in command No. 2).-sC: runs NSE scripts from the default category. This is a set of scripts considered safe, fast, and relevant for an initial analysis. It’s the equivalent of--script default: configuration details, anonymous FTP access checks, web page title retrieval, SMB analysis, and more.-T4: applies a performance profile that reduces packet wait times and speeds up the scan. Nmap offers 6 levels from T0 to T5; T4 is generally used on local networks or test environments. Use with caution on industrial or fragile equipment.--top-ports 1024: limits the scan to the 1024 most common TCP ports, which offers a good balance between coverage and speed. You can move to--top-ports 2000or-p-if you have time.-oA scan_réseau: saves the results in three formats at once, normal text (.nmap), XML (.xml), and greppable (.gnmap). The XML format is especially useful for importing results into other tools (Metasploit, Python scripts, etc.); the greppable format lets you quickly filter results with grep from the command line.
Now that’s a command that starts to look like a real professional Nmap use case!
As a habit, always save your scans in all three formats with
-oA. You never know whether you’ll need to reprocess the results later, import the data into another tool, or simply compare two scans performed at different dates.
To go even further, here is the full version as you might find it in real auditing contexts, with a target list in a file and an exclusion for sensitive equipment:
# Full version with target file and exclusion
nmap -sV -sC -T4 --top-ports 1024 -oA scan_réseau -iL /tmp/cibles.txt --exclude 192.168.1.250This command shows that running a simple nmap <IP> is nowhere near enough to properly assess network security, perform correct mapping, or validate a newly implemented filtering policy.
Conclusion
In this article, we looked at five Nmap commands covering the most common uses, from basic network inventory to vulnerability auditing, including SMB and HTTP configuration checks. These same commands, and many others, are explained in detail in my book:

There’s still a lot to say about Nmap: advanced TCP scan types (SYN, FIN, XMAS, Null, ACK), importing XML results into Python or PowerShell, using it with Metasploit or Aquatone, and of course the hundreds of NSE scripts available for protocols we didn’t cover here (FTP, SNMP, MSSQL, SSH, VNC…). This tool is a real gold mine for anyone willing to explore it.
Feel free to share your thoughts in the comments or come chat with our community on our Discord server! And if you have Nmap commands you use every day that aren’t in this top 5, share them—we’d be delighted to discover them.


