nmap Linux Command
Network exploration tool and port scanner (basic usage).
What does nmap do?
Network exploration tool and port scanner (basic usage).
Syntax
nmap [options] targetPractical example
nmap -sV 192.168.1.1Questions about nmap
How do I scan all ports on a target?
Use `nmap -p- target` to scan all 65535 ports. Use `-p 1-1024` to scan only the first 1024 well-known ports.
How do I detect service versions?
Use `nmap -sV target` to detect the version of services running on open ports. This helps identify vulnerable software versions.
How do I do a quick scan?
Use `nmap -T4 target` for faster scanning, or `nmap -F target` for a fast scan of only the most common ports.
How do I scan a subnet?
Use `nmap 192.168.1.0/24` to scan an entire /24 subnet. This will discover all active hosts and their open ports.
How do I do a stealth scan?
Use `nmap -sS target` for a SYN scan (half-open scan). This is faster and less likely to be logged than a full TCP connect scan.
How do I scan UDP ports?
Use `nmap -sU target` to scan UDP ports. UDP scanning is slower than TCP because it is connectionless.
How do I do OS detection?
Use `nmap -O target` to attempt OS detection. Note that this requires root privileges on most systems.
How do I output results to a file?
Use `nmap -oN output.txt target` for normal output, `-oX output.xml` for XML, or `-oG output.gnmap` for grepable format.
Related Networking Commands
iwconfigDisplays and configures wireless network interface parameters.
pingSends ICMP echo request packets to test network connectivity to a host.
hostnameShows or sets the system's hostname.
ifconfigDisplays or configures network interface parameters (deprecated, use ip).
routeDisplays and modifies the IP routing table.
ipModern replacement for ifconfig. Shows and manipulates routing, devices, and tunnels.