Cyberithub

How to Install Nmap on Ubuntu 22.04 [Working Steps]

Advertisements

In this article, we will see how to install nmap on Ubuntu 22.04. Nmap, also known as network mapper is a free and very powerful open source network discovery and security auditing tool used for performing various types of tasks including discovering devices on a network, identifying host, services, ports, operating systems and much more. It has wide range of features and options to customize your scanning and discovery of devices in a network. It is very frequently used by network administrators, security professionals, penetration testers and by many other professionals.

The powerful scripting engine of Nmap allows us to write scripts to enhance functionality and automate complex tasks in a very effective manner. It is now so popular used that it has find its usage on multiple electronic devices and platforms. It is quite easy to download and install on almost all the famous platforms including Linux, Windows and Unix based platforms. Here we will see the steps to download and install Nmap on Ubuntu 22.04 based systems.

 

How to Install Nmap on Ubuntu 22.04 [Working Steps]

How to Install Nmap on Ubuntu 22.04 [Working Steps]

Also Read: How to Install fping on Ubuntu 22.04 [Easy Steps]

Step 1: Prerequisites

a) You should have a running Ubuntu 22.04 Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility available in your Server.

d) You should have snap utility available in your system in case you are looking to install nmap as snap package.

 

Step 2: Update Your Server

It is always a good practice to look for all the latest available updates and install them using sudo apt update && sudo apt upgrade command before installing any new packages in the system. It is because latest updates carries lot of security and bug fixes which ultimately helps in making system safe and secure from external vulnerabilities.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:2 https://artifacts.elastic.co/packages/8.x/apt stable InRelease
Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Hit:5 https://ngrok-agent.s3.amazonaws.com buster InRelease
Get:6 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Hit:7 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages [363 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [526 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [953 kB]
Get:11 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [188 kB]
Get:12 http://security.ubuntu.com/ubuntu jammy-security/universe i386 Packages [564 kB]
Get:13 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [794 kB]
Get:14 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [146 kB]
Get:15 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,162 kB]
Get:16 http://in.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [247 kB]
Get:17 http://in.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [1,114 kB]
Get:18 http://in.archive.ubuntu.com/ubuntu jammy-updates/restricted i386 Packages [32.8 kB]
Get:19 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe i386 Packages [663 kB]
Get:20 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [997 kB]
Get:21 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [219 kB]
Fetched 8,198 kB in 11s (770 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
apt apt-transport-https apt-utils firmware-sof-signed libapt-pkg6.0 ubuntu-drivers-common
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

 

Step 3: Install Nmap

After installing all the latest updates, you can use any of the below methods to install Nmap on your system depending on your tools availability and requirements.

a) Using Apt

If you are looking to install nmap from default ubuntu repo then you can use either sudo apt install nmap or sudo apt-get install nmap to download and install the package along with all its required dependencies.

cyberithub@ubuntu:~$ sudo apt install nmap
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libblas3 liblinear4 lua-lpeg nmap-common
Suggested packages:
liblinear-tools liblinear-dev ncat ndiff zenmap
The following NEW packages will be installed:
libblas3 liblinear4 lua-lpeg nmap nmap-common
0 upgraded, 5 newly installed, 0 to remove and 6 not upgraded.
Need to get 5,973 kB of archives.
After this operation, 26.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
...............................................

b) Using Snap

If you are looking to install nmap as snap package then you can install it by running sudo snap install nmap command as shown below.

cyberithub@ubuntu:~$ sudo snap install nmap
nmap 7.94 from Maximiliano Bertacchini (maxiberta) installed

 

Step 4: Check Version

You can check the current installed version by using nmap --version command as shown below. As you can see from output, the current installed version is 7.80.

cyberithub@ubuntu:~$ nmap --version
Nmap version 7.80 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
Compiled with: liblua-5.3.6 openssl-3.0.2 nmap-libssh2-1.8.2 libz-1.2.11 libpcre-8.39 libpcap-1.10.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

 

Step 5: Using Nmap

It is now time to test nmap application by running a ping scan(-sn) on IP address 8.8.8.8 using nmap -sn 8.8.8.8 command as shown below. This will show if the target host is up or not. As you can see from output, host is up and running.

cyberithub@ubuntu:~$ nmap -sn 8.8.8.8
Starting Nmap 7.80 ( https://nmap.org ) at 2023-11-15 23:21 IST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.032s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

 

Step 6: Check all available options

You can check all the options available with nmap command using nmap --help command as shown below.

cyberithub@ubuntu:~$ nmap --help
Nmap 7.80 ( https://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
  -sL: List Scan - simply list targets to scan
  -sn: Ping Scan - disable port scan
  -Pn: Treat all hosts as online -- skip host discovery
  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -PO[protocol list]: IP Protocol Ping
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
  --traceroute: Trace hop path to each host
....................................................

 

Step 7: Uninstall Nmap

Once you are done using Nmap, you can choose to uninstall it from your system by using any of the below methods depending on how you installed it.

a) Using Apt

If you installed from default ubuntu repo then to uninstall, run sudo apt remove nmap command as shown below. To remove all the dependencies along with nmap package, use --auto-remove option with below command. But be very careful in removing dependent packages as sometimes those packages are used by some other active running applications in your system. In that case, removal can cause irreparable application and data loss in your system.

cyberithub@ubuntu:~$ sudo apt remove nmap
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libblas3 liblinear4 lua-lpeg nmap-common
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
nmap
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 4,341 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 236574 files and directories currently installed.)
Removing nmap (7.91+dfsg1+really7.80+dfsg1-2ubuntu0.1) ...
Processing triggers for man-db (2.10.2-1) ...

b) Using Snap

If you installed as snap package then to uninstall, run sudo snap remove nmap command as shown below.

cyberithub@ubuntu:~$ sudo snap remove nmap
nmap removed

Leave a Comment