The Network Mapper, also known as “Nmap,” is a versatile, flexible, and famous tool used to manage and secure networks. It helps administrators to map their networks and security scans.

Through command-line prompt Nmap, the tool provides multiple features such as exploring networks, finding open ports, ping sweeps, OS detection, and many more.

This post is focusing on how to use the Nmap command in the terminal with detailed examples. Let’s check them one by one:

How to install Nmap Command

Before exploring with Nmap commands, the Nmap scanner tool must have installed on your system. So, if it is not downloaded yet, get it by opening up the terminal and executing the following command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-01.png" data-lazy- height="768" src="data:image/svg xml,” width=”974″>

Once the download and installation are done, check the various functions and operations of the Nmap command with examples:

How to scan hostname using Nmap command

To perform a scan using hostname and IP address is the best way to run Nmap commands. For example, I set the hostname as “linuxhint.com”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-02.png" data-lazy- height="437" src="data:image/svg xml,” width=”974″>

How to scan IP address using Nmap command

Use mentioned command in terminal to scan through IP address:

$ sudo nmap 192.168.18.68

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-03.png" data-lazy- height="343" src="data:image/svg xml,” width=”974″>

How to scan using the “–v” option with Nmap Command

The -v command is used to get a more elaborative detail about the connected machine. So, type command in terminal:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-04-1.png" data-lazy- height="604" src="data:image/svg xml,” width=”974″>

IP Address Range

It is easy to specify the IP range using the Nmap scanner tool, use the command given below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-06.png" data-lazy- height="460" src="data:image/svg xml,” width=”974″>

How to enable OS detection with Nmap

Nmap scanner tool helps to detect operating system and version as well running on the localhost. If you want to get OS details, you can use “-O”:

$ sudo nmap -O linuxhint.com

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-07.png" data-lazy- height="662" src="data:image/svg xml,” width=”974″>

How to Detect Firewall

To check if the local host is using any Firewall, type “-sA” in the terminal with “nmap”:

$ sudo nmap -sA 192.168.18.68

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-08.png" data-lazy- height="277" src="data:image/svg xml,” width=”974″>

As it can be seen in the above result that no packet is filtered.

How to find a Live host

Type “-sP” to scan a list of all live and up hosts:

$ sudo nmap -sP 192.168.18.*

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-09.png" data-lazy- height="589" src="data:image/svg xml,” width=”754″>

How to Perform Fast Scan with Nmap

Use the “-F” flag with Nmap in a terminal, and it will perform a fast scan for the ports listed in Nmap services:

$ sudo nmap –F 192.168.18.68

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-10.png" data-lazy- height="325" src="data:image/svg xml,” width=”912″>

How to find Nmap Version

Find out the Nmap version to update the latest version of the previous one that is old.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-11.png" data-lazy- height="239" src="data:image/svg xml,” width=”885″>

How to Print host interfaces and routes using Nmap

The “-iflist” command is used to find out routes and hosts interface information. Use the below-mentioned command to perform this scan:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-12.png" data-lazy- height="577" src="data:image/svg xml,” width=”735″>

How to scan Specific Port with Nmap

If you want to list out details of a specific port, type “-p”; otherwise Nmap scanner will scan TCP ports by default:

$ sudo nmap -p 80 linuxhint.com

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-13.png" data-lazy- height="412" src="data:image/svg xml,” width=”974″>

How to scan TCP Ports

All open ports TCP ports can be scanned through 8.8.8.8:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-14.png" data-lazy- height="350" src="data:image/svg xml,” width=”974″>

How to scan UDP Ports

All open ports UDP ports can be seen through the following command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-15.png" data-lazy- height="306" src="data:image/svg xml,” width=”893″>

Most Common Ports with TCP Sync

Check the most commonly used ports through –sT that is sync with TCP ports.

Type:

$ sudo nmap -sT 192.168.18.68

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-16.png" data-lazy- height="252" src="data:image/svg xml,” width=”881″>

TCP Null Scan to Fool a Firewall

Following -sN command will help to show TCP null scan to fool a firewall:

$sudo nmap -sN linuxhint.com

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/03/echo/Use-Nmap-Command-Ubuntu-17.png" data-lazy- height="270" src="data:image/svg xml,” width=”887″>

Conclusion

Nmap is a scanner tool used to help network administrators to secure their networks. Using this guide, we have learned that how the Nmap tool and its functionality work with examples.

About the author

<img alt="Avatar" data-lazy-src="https://secure.gravatar.com/avatar/81ddc0268829514e304c7a0bfa2cc3f8?s=112&r=g" height="112" src="data:image/svg xml,” width=”112″>

Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.