Ubuntu Linux

How to Install Nmap on Ubuntu

Nmap is a network scanning tool to identify open ports and running services on a computer. It is a useful networking tool for gathering information about a computer or a network.

You can check whether Nmap is already installed on your Ubuntu system by running the following command:

nmap --version

You will see the Nmap version if it is already installed. If not, run the following command to install Nmap on Ubuntu:

sudo apt update
sudo apt install nmap

Nmap Command Examples

Check open ports on your local Ubuntu system:

nmap localhost

Scan a network to find all running devices on the network:

nmap -sn 192.168.1.0/24

Use the -p option to only scan specific port(s):

nmap -p 80 192.168.1.10
nmap -p 22,80 192.168.1.10
nmap -p 22-1000 192.168.1.10

Check if UDP port 53 is open:

nmap -p U:53 192.168.1.10

Check if TCP port 21 is open:

nmap -p T:21 192.168.1.10

Include the version of running services:

nmap -sV 192.168.1.10

Try to detect the operating system running on the remote computer with -O switch:

sudo nmap -O 192.168.1.10

Save the scan result to a file called output.txt:

nmap -oN output.txt 192.168.1.10

Read targets from a text file called targets.txt. The text file will contain a list of IP addresses or hostnames to be scanned (one IP per line):

nmap -iL targets.txt

There are a lot of options available with the nmap command. To see all command options, type man nmap in the command prompt.

Run nmap scan to check open ports
Find all running devices on the network
Include the version of running services:
Detect the operating system of a remote computer