ToolXON Blog

Nmap Commands

Nmap commands: A responsible Nmap starter for discovering open ports and services on authorized networks, with output-saving and scanning-scope guidance. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.

Before you start

Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.

Syntax at a glance

Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.

Quick command reference

CommandWhat it doesExampleUseful options
nmap HOSTScan common TCP ports on a hostnmap scanme.nmap.org-F scans fewer ports; -Pn skips host discovery
nmap -sVProbe open ports to identify service versionsnmap -sV 192.0.2.10-sC runs default scripts; -T4 increases timing aggressiveness
nmap -pChoose which ports to scannmap -p 22,80,443 192.0.2.10-p 1-1024 scans a range; -p- selects all TCP ports
nmap -oNSave human-readable scan outputnmap -oN scan.txt scanme.nmap.org-oX writes XML; -oA writes several formats
nmap --scriptRun selected NSE scriptsnmap --script http-title scanme.nmap.org--script-help lists script descriptions

Command syntax and examples explained

1. nmap HOST

Purpose: Scan common TCP ports on a host.

Syntax

nmap [OPTIONS] HOST

Example

nmap scanme.nmap.org

Options and notes: -F scans fewer ports; -Pn skips host discovery.

Only scan systems you own or have explicit permission to test.

2. nmap -sV

Purpose: Probe open ports to identify service versions.

Syntax

nmap -sV HOST

Example

nmap -sV 192.0.2.10

Options and notes: -sC runs default scripts; -T4 increases timing aggressiveness.

Version detection creates more traffic than a simple port scan.

3. nmap -p

Purpose: Choose which ports to scan.

Syntax

nmap -p PORTS HOST

Example

nmap -p 22,80,443 192.0.2.10

Options and notes: -p 1-1024 scans a range; -p- selects all TCP ports.

Large scans may take time and can trigger monitoring alerts.

4. nmap -oN

Purpose: Save human-readable scan output.

Syntax

nmap -oN FILE HOST

Example

nmap -oN scan.txt scanme.nmap.org

Options and notes: -oX writes XML; -oA writes several formats.

Store results securely; scan output can reveal network topology.

5. nmap --script

Purpose: Run selected NSE scripts.

Syntax

nmap --script SCRIPT HOST

Example

nmap --script http-title scanme.nmap.org

Options and notes: --script-help lists script descriptions.

Use specific low-impact scripts first; avoid intrusive scripts without written authorization.

Common mistakes and troubleshooting

  • Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
  • Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
  • Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
  • Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.

Safety tips

Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.

Frequently asked questions

Do these commands work on every system?

Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.

Can I copy and run every example exactly?

Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.

Conclusion

Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.