Network
The nmap command
Scans hosts and ports to see which services are exposed. Only with permission.
Most useful options
-snOnly discovers which hosts are up, without scanning ports-PnTreats all targets as up and skips host discovery. Useful when the host blocks pings-p <puertos>Scans only the given ports, such as 22,80 or 1-1000-FFast scan with fewer ports than the default scan-sVDetects the name and version of services answering on open ports-OTries to identify the operating system. It needs administrator privileges-AEnables OS detection, version detection, scripts and traceroute at once. It is noisier--openShows only open or possibly open portsCopy-ready examples
$ nmap localhostopen ports on your own machine.$ nmap -sV localhostthe same, with the version of each service that answers.$ nmap -p 22,80,443 localhostchecks only those three ports on your machine.$ nmap -sn 192.168.1.0/24lists the active hosts on your local network. Only on networks you own or are authorised to test in writing.$ nmap -v scanme.nmap.orgtest permitted by the Nmap project. Scanning only, no exploits or denial-of-service attacks, and no more than a dozen scans a day.You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- Scanning other people's hosts without permission can be illegal and usually breaks the provider's rules. Scan only what is yours or authorised in writing.
- A filtered port is not closed: the firewall drops packets without answering, and nmap cannot see what is behind it.
- Without administrator privileges, scan types such as SYN or OS detection are not available.
- With -F or -p fewer ports are probed: an open port not showing up does not prove there is no service.
Differences from similar commands
- ss: shows the ports and connections of your own machine, without looking at other hosts. nmap probes other machines.
- nc: tests one specific port on a host. nmap walks many ports and detects services.
- ping: checks whether a machine answers a packet. nmap with -sn does the same for many machines at once.
Security
Scan only your own hosts or those you are authorised to test in writing. A scan can trigger alarms in a firewall or intrusion detection system on someone else's network.
FAQ
What is it for in real work?
To inventory services, check firewalls and authorised security audits.
Can I scan my home network?
Yes, if it is yours. Start with -sn to see which hosts are there, then scan ports only on the ones you care about.
Why does it take so long?
By default it probes the 1000 most common ports, and filtered ones force it to wait. With -F or -p you shrink the list and the time drops.
What is scanme.nmap.org?
A host the Nmap project offers for practice. It allows scanning with Nmap, without exploits or denial-of-service, and at a low rate.
More Network commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course