Nmap beginner guide banner showing terminal commands and network discovery
Linux networking guide

What Is Nmap? Install, Basics and Useful Examples

Nmap is one of the best-known command line tools for network discovery and port checking. This guide explains what it does, how to install it on Linux, the legal/authorisation basics, and some safe everyday examples for admins and learners.

Overview

What is Nmap?

Nmap, short for Network Mapper, is a command line tool used to discover hosts, check open ports and identify services on a network. It is commonly used by system administrators, network engineers, security teams and people learning how networks work.

In simple terms, Nmap helps answer questions like:

Is this host online?

nmap -sn 192.168.1.10

Which ports are open?

nmap -p 22,80,443 example.com

What service is listening?

nmap -sV -p 22,80,443 example.com

Can I save a report?

nmap -oN nmap-report.txt example.com
For quick command generation, use the Nmap Command Builder. For a compact reference, keep the Nmap Cheat Sheet open.

How to install Nmap on Linux

Nmap is available in most Linux package repositories. Use the command that matches your distribution.

Ubuntu or Debian

sudo apt update
sudo apt install nmap

AlmaLinux, Rocky Linux, RHEL or CentOS

sudo dnf install nmap

Fedora

sudo dnf install nmap

Arch Linux

sudo pacman -S nmap

Check it installed correctly

nmap --version

You can also find official downloads and documentation on the Nmap website.

Basic Nmap syntax

nmap [options] target

The target can be a hostname, IP address, IP range or a file containing a target list.

Target typeExample
Hostnamenmap example.com
Single IPnmap 192.168.1.10
Small subnetnmap 192.168.1.0/24
Target filenmap -iL targets.txt

Common options

OptionMeaningExample
-snHost discovery onlynmap -sn 192.168.1.0/24
-pSelect portsnmap -p 22,80,443 example.com
-sVService/version detectionnmap -sV example.com
-nSkip DNS lookupsnmap -n example.com
--openShow open ports onlynmap --open example.com
-oNSave normal outputnmap -oN scan.txt example.com

Useful Nmap examples

Check a website's common ports

nmap -p 80,443 example.com

Useful when checking whether HTTP and HTTPS appear reachable.

Check SSH and web ports

nmap -sV -p 22,80,443 server.example.com

Adds service detection for common server ports.

Find live hosts on a small LAN

nmap -sn -n 192.168.1.0/24

Skips DNS lookups and checks which hosts appear up.

Scan top 100 ports

nmap --top-ports 100 example.com

A focused check of common ports.

Save a normal report

nmap -sV -p 22,80,443 -oN nmap-report.txt example.com

Helpful for ticket notes, admin reports or comparing results later.

Basic UDP check

nmap -sU -p 53,123 192.168.1.10

UDP scans can be slower, so keep the port list small.

A safe beginner workflow

  1. Confirm authorisation and scope.
  2. Start with a single host or a small range.
  3. Use -sn if you only need host discovery.
  4. Use -p to limit the port list.
  5. Add -sV only when service details are useful.
  6. Save output with -oN or -oA if you need a record.

To avoid memorising every flag, generate a command with the Nmap Command Builder, then keep the Nmap Cheat Sheet nearby as a reference.

Next steps

Nmap is easiest to learn by starting with small, authorised checks and gradually adding options. Use the builder for command generation, then use the cheat sheet to understand what each flag does.

FAQ

Is Nmap legal?

Nmap is a legitimate tool, but you should only scan systems you own or are authorised to test.

What is Nmap used for?

It is commonly used for host discovery, port checking, service detection and network inventory tasks.

How do I install Nmap on Ubuntu?

Run sudo apt update and then sudo apt install nmap.

What is the safest Nmap command to start with?

A simple host discovery command such as nmap -sn 192.168.1.0/24 is a good starting point on a network you are authorised to check.

Where can I build Nmap commands?

Use the Nmap Command Builder to generate common commands without memorising every option.

External references

Safe admin examples

Safe Nmap examples for authorised admin checks

# Check if a host is up
nmap -sn 192.168.1.10

# Check common ports on your own server
nmap --top-ports 20 example.com

# Check specific ports
nmap -p 22,80,443 example.com

# Detect service versions on authorised systems
nmap -sV -p 22,80,443 example.com
Only scan systems you own or have explicit permission to test. For guided examples, use the Nmap Command Builder.
FAQ

Frequently Asked Questions

What is Nmap used for?

Nmap is used for authorised network discovery, host checks, port scans and service detection.

Is Nmap legal to use?

Nmap is legal when used on systems you own or are authorised to test. Unauthorised scanning may violate policies or laws.

How do I scan specific ports with Nmap?

Use -p followed by ports, for example nmap -p 22,80,443 example.com.

What does nmap -sV do?

-sV attempts to detect service versions on open ports.

$ practise_next --topic linux

Practise this next

Turn the guide into practice with a related quiz, builder, cheat sheet or learning path.