Debian / Ubuntu Linux: Install nmap command Software For Scanning Network

last updated in Categories , ,

How do I install nmap command under a Debian or Ubuntu Linux based system for testing security of my own network?

Nmap is a command line tool for network exploration or security auditing. It supports ping scanning (determine which hosts are up), many port scanning techniques (determine what services the hosts are offering), and TCP/IP fingerprinting (remote host operating system identification).
how to install nmap command on debian ubuntu linux using apt-get
This page shows how to install nmap command on a Debian or Ubuntu Linux based system.

Installation

To install nmap for Debian and Ubuntu Linux based server systems type the following apt command or apt-get command:
$ sudo apt-get install nmap
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  liblinear3 ndiff python-bs4 python-html5lib python-lxml python-webencodings
Suggested packages:
  liblinear-tools liblinear-dev python-genshi python-lxml-dbg python-lxml-doc
The following NEW packages will be installed:
  liblinear3 ndiff nmap python-bs4 python-html5lib python-lxml python-webencodings
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,518 kB of archives.
After this operation, 29.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu artful/main amd64 liblinear3 amd64 2.1.0+dfsg-2 [39.3 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-bs4 all 4.6.0-1 [67.9 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-webencodings all 0.5-2 [10.3 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-html5lib all 0.999999999-1 [83.6 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu artful/main amd64 python-lxml amd64 4.0.0-1 [1,120 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu artful/main amd64 ndiff all 7.60-1ubuntu1 [20.4 kB]                                                                                                                     
Get:7 http://in.archive.ubuntu.com/ubuntu artful/main amd64 nmap amd64 7.60-1ubuntu1 [5,176 kB]                                                                                                                   
Fetched 6,518 kB in 22s (284 kB/s)                                                                                                                                                                                
Selecting previously unselected package liblinear3:amd64.
(Reading database ... 196139 files and directories currently installed.)
Preparing to unpack .../0-liblinear3_2.1.0+dfsg-2_amd64.deb ...
Unpacking liblinear3:amd64 (2.1.0+dfsg-2) ...
Selecting previously unselected package python-bs4.
Preparing to unpack .../1-python-bs4_4.6.0-1_all.deb ...
Unpacking python-bs4 (4.6.0-1) ...
Selecting previously unselected package python-webencodings.
Preparing to unpack .../2-python-webencodings_0.5-2_all.deb ...
Unpacking python-webencodings (0.5-2) ...
Selecting previously unselected package python-html5lib.
Preparing to unpack .../3-python-html5lib_0.999999999-1_all.deb ...
Unpacking python-html5lib (0.999999999-1) ...
Selecting previously unselected package python-lxml.
Preparing to unpack .../4-python-lxml_4.0.0-1_amd64.deb ...
Unpacking python-lxml (4.0.0-1) ...
Selecting previously unselected package ndiff.
Preparing to unpack .../5-ndiff_7.60-1ubuntu1_all.deb ...
Unpacking ndiff (7.60-1ubuntu1) ...
Selecting previously unselected package nmap.
Preparing to unpack .../6-nmap_7.60-1ubuntu1_amd64.deb ...
Unpacking nmap (7.60-1ubuntu1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Setting up python-bs4 (4.6.0-1) ...
Setting up python-lxml (4.0.0-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up liblinear3:amd64 (2.1.0+dfsg-2) ...
Setting up python-webencodings (0.5-2) ...
Setting up nmap (7.60-1ubuntu1) ...
Setting up ndiff (7.60-1ubuntu1) ...
Setting up python-html5lib (0.999999999-1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...

Examples

To find the nmap version, enter:
# nmap -V
OR
# nmap --version
Sample outputs:

Nmap version 7.60 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
Compiled with: liblua-5.3.3 openssl-1.0.2g nmap-libssh2-1.8.0 libz-1.2.8 libpcre-8.39 libpcap-1.8.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

So I am using namp version 7.60 on a Ubuntu Linux.

WARNING! nmap scan could get you into legal trouble if you don’t have permission to scan the target systems.

To scan an IP address, enter:
# nmap 192.168.1.2
OR
$ sudo nmap 192.168.1.1
Sample outputs:

[sudo] password for vivek: 
 
Starting Nmap 7.60 ( https://nmap.org ) at 2017-11-08 13:53 IST
Nmap scan report for gateway (192.168.1.1)
Host is up (0.23s latency).
Not shown: 994 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
23/tcp   open  telnet
53/tcp   open  domain
80/tcp   open  http
5431/tcp open  park-agent
MAC Address: 10:62:EB:6A:DB:FD (D-Link International)
 
Nmap done: 1 IP address (1 host up) scanned in 4.65 seconds

To scan a range of IP addresses, enter:
# nmap 192.168.1.2-10
To scan an entire subnet:
# nmap 192.168.1.0/24
More examples:

## Ping only scan ##
nmap -sP 192.168.1.2
 
## Scan and do traceroute ##
nmap --traceroute IP-ADDRESS
nmap --traceroute DOMAIN-NAME-HERE
 
## TCP SYN Scan ##
nmap -sS 192.168.1.2
 
## UDP Scan ##
nmap -sU 192.168.1.2
 
## IP protocol scan ##
nmap -sO 192.168.1.2
 
## Scan port 80, 25, 443 ##
nmap -p 80 192.168.1.2
nmap -p http 192.168.1.2
nmap -p 25 192.168.1.2
nmap -p smtp 192.168.1.2
nmap -p 443 192.168.1.2
nmap -p 80,24,443 192.168.1.2
 
## Scan port ranges ##
nmap -p 512-1024 192.168.1.2
 
## Scan for OS i.e. Operating System Detection ##
nmap -O 192.168.1.2
nmap -O --osscan-guess 192.168.1.2
 
## Scan for application server version ##
nmap -sV 192.168.1.2

Type the following command to read nmap man page or see our 32 nmap command examples:
$ man nmap

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):