Nmap Commands
Comprehensive Nmap commands and workflows for network discovery and security auditing across all platforms.
Installation
Linux/Ubuntu
# Package manager installation
sudo apt update && sudo apt install nmap
# Alternative: Download from official source
wget https://releases.nmap.com/latest/nmap-linux.tar.gz
tar -xzf nmap-linux.tar.gz
sudo mv nmap /usr/local/bin/
# Kali Linux
sudo apt install nmap
macOS
# Using Homebrew
brew install nmap
# Using MacPorts
sudo port install nmap
# Manual installation
curl -O https://releases.nmap.com/latest/nmap-macos.pkg
sudo installer -pkg nmap-macos.pkg -target /
Windows
# Using Chocolatey
choco install nmap
# Using Scoop
scoop install nmap
# Using winget
winget install nmap
# Manual download from official website
# Visit https://nmap.com/download
Basic Commands
Command |
Description |
nmap --help |
Show help information |
nmap --version |
Display version information |
nmap -h <target> |
Basic scan of target |
nmap -v <target> |
Verbose scan of target |
nmap -o <file> |
Save output to file |
nmap -i <input> |
Read input from file |
nmap -p <port> |
Specify port number |
nmap -t <timeout> |
Set timeout value |
Advanced Commands
Command |
Description |
nmap -A <target> |
Aggressive scan mode |
nmap -sS <target> |
Stealth SYN scan |
nmap -sU <target> |
UDP scan |
nmap -O <target> |
OS detection |
nmap -sV <target> |
Version detection |
nmap --script <script> |
Run NSE scripts |
nmap -T4 <target> |
Timing template |
nmap -f <target> |
Fragment packets |
Configuration
Command |
Description |
nmap config --list |
Show current configuration |
nmap config --set <key> <value> |
Set configuration value |
nmap config --get <key> |
Get configuration value |
nmap config --unset <key> |
Remove configuration value |
nmap config --global <key> <value> |
Set global configuration |
Common Use Cases
Network Scanning
# Basic port scan
nmap -p 1-1000 192.168.1.1
# Service version detection
nmap -sV -p 22,80,443 target.com
# OS fingerprinting
nmap -O target.com
Vulnerability Assessment
# Script scan for vulnerabilities
nmap --script vuln target.com
# Comprehensive scan
nmap -A -T4 target.com
# Save results to file
nmap -oA scan_results target.com
Troubleshooting
Issue |
Solution |
Command not found |
Ensure nmap is installed and in PATH |
Permission denied |
Use sudo or check file permissions |
Connection timeout |
Check network connectivity and firewall |
Invalid syntax |
Verify command syntax and parameters |
Version conflicts |
Update to latest version or check compatibility |
Tips and Tricks
- Use
nmap --help
for command-specific help
- Check
nmap --version
to verify installation
- Use tab completion for faster command entry
- Create aliases for frequently used commands
- Keep nmap updated to latest version
- Nmap - Network discovery and security auditing
- Metasploit - Penetration testing framework
- Burp Suite - Web application security testing
- Wireshark - Network protocol analyzer
Resources
Last updated: 2025-07-05|Edit on GitHub