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.
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.10Which ports are open?
nmap -p 22,80,443 example.comWhat service is listening?
nmap -sV -p 22,80,443 example.comCan I save a report?
nmap -oN nmap-report.txt example.comLegal and authorisation basics
Before running a scan, make sure you know:
- Who owns the target system or network.
- Whether you have permission to scan it.
- What scope is allowed, such as one host, one subnet or specific ports.
- Whether the scan could trigger monitoring alerts or rate limits.
- Where to save or report your findings.
This guide focuses on normal discovery and admin troubleshooting. It avoids stealth, spoofing, exploit scripts and evasion-style options.
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 type | Example |
|---|---|
| Hostname | nmap example.com |
| Single IP | nmap 192.168.1.10 |
| Small subnet | nmap 192.168.1.0/24 |
| Target file | nmap -iL targets.txt |
Common options
| Option | Meaning | Example |
|---|---|---|
-sn | Host discovery only | nmap -sn 192.168.1.0/24 |
-p | Select ports | nmap -p 22,80,443 example.com |
-sV | Service/version detection | nmap -sV example.com |
-n | Skip DNS lookups | nmap -n example.com |
--open | Show open ports only | nmap --open example.com |
-oN | Save normal output | nmap -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
- Confirm authorisation and scope.
- Start with a single host or a small range.
- Use
-snif you only need host discovery. - Use
-pto limit the port list. - Add
-sVonly when service details are useful. - Save output with
-oNor-oAif 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 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
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.