Table of Contents
In this article, I will take you through the steps to install nmap command on Linux. Nmap is a free and open source network scanning tool widely used by network and security teams around the world. It was created by Gordon Lyon Nmap to discover hosts and services running on a computer network. It is a very handy tool for scanning network and system vulnerabilities on a large scale but it also works fine on a single host.
Due to the number of features it provides, it is very popularly used by penetration testers and ethical hackers. Nmap runs on almost all the major available operating systems quite smoothly. You can either download the binary file from official website and use or you can also download and install nmap command from the default available repository. Here we will see the steps to install Nmap command on Linux based systems from the default repo.

How to Install Nmap command on Linux (RHEL/CentOS 7/8)
Also Read: How to Install Compress - Video Compressor on Ubuntu 20.04 LTS
Step 1: Prerequisites
a) You should have a running Linux(RHEL/CentOS 7/8) Server.
b) You should have sudo or root access to run privileged commands.
c) You should have yum or dnf utility available in your System.
Step 2: Update Your Server
Before proceeding with the steps to install nmap command on your system, it is best to first sync all your installed packages to the latest version by using yum update && yum upgrade command as shown below. Similarly, if you have dnf utility available then you can use dnf update && dnf upgrade command.
NOTE:
root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.[root@localhost ~]# yum update && yum upgrade
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 7.0 kB 00:00:00
* base: mirrors.nxtgen.com
* commercial-addons: repo.issabel.org
* epel: repo.extreme-ix.org
* extras: mirrors.nxtgen.com
* issabel-base: repo.issabel.org
* issabel-extras: repo.issabel.org
* issabel-updates: repo.issabel.org
* updates: mirrors.nxtgen.com
base | 3.6 kB 00:00:00
commercial-addons | 951 B 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
issabel-base | 951 B 00:00:00
issabel-extras | 951 B 00:00:00
issabel-updates | 951 B 00:00:00
updates | 2.9 kB 00:00:00
(1/4): epel/x86_64/group_gz | 99 kB 00:00:00
(2/4): epel/x86_64/updateinfo | 1.0 MB 00:00:04
(3/4): updates/7/x86_64/primary_db | 19 MB 00:00:05
(4/4): epel/x86_64/primary_db | 7.0 MB 00:00:10
commercial-addons/x86_64/primary | 7.5 kB 00:00:00
commercial-addons 45/45
Resolving Dependencies
--> Running transaction check
---> Package dkms.noarch 0:3.0.8-1.el7 will be updated
---> Package dkms.noarch 0:3.0.10-1.el7 will be an update
......................................................
Step 3: Install Nmap
In the next step, you can install nmap from default repo by using yum install nmap command as shown below. This will download and install the package along with all its required dependencies. Similarly, if you are having dnf utility then you can use dnf install nmap command to install the package.
[root@localhost ~]# yum install nmap Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.nxtgen.com * commercial-addons: repo.issabel.org * epel: repo.extreme-ix.org * extras: mirrors.nxtgen.com * issabel-base: repo.issabel.org * issabel-extras: repo.issabel.org * issabel-updates: repo.issabel.org * updates: mirrors.nxtgen.com Resolving Dependencies --> Running transaction check ---> Package nmap.x86_64 2:6.40-19.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================= Installing: nmap x86_64 2:6.40-19.el7 base 3.9 M Transaction Summary ============================================================================================================================================================= Install 1 Package Total download size: 3.9 M Installed size: 16 M Is this ok [y/d/N]: Y ................................................
Step 4: Verify Installation
After successful installation, you can verify the package by queries rpm database using rpm -qa | grep -i nmap command. If the package is installed then it should show like below.
[root@localhost ~]# rpm -qa | grep -i nmap nmap-6.40-19.el7.x86_64 nmap-ncat-6.40-19.el7.x86_64
Step 5: Check Version
You can also verify the current installed version by using nmap --version command as shown below.
[root@localhost ~]# nmap --version Nmap version 6.40 ( http://nmap.org ) Platform: x86_64-redhat-linux-gnu Compiled with: nmap-liblua-5.2.2 openssl-1.0.2k libpcre-8.32 libpcap-1.5.3 nmap-libdnet-1.12 ipv6 Compiled without: Available nsock engines: epoll poll select
Step 6: Using Nmap
Now that Nmap utility is successfully installed, you can now use it to scan a server or a host. For example, here we are scanning host google.com by simply using nmap google.com command as shown below. After scanning the host you will see a report like below where it will display the host running status and the state of all the ports scanned.
[root@localhost ~]# nmap google.com Starting Nmap 6.40 ( http://nmap.org ) at 2023-01-25 15:46 EST Nmap scan report for google.com (142.250.77.110) Host is up (0.012s latency). rDNS record for 142.250.77.110: maa05s15-in-f14.1e100.net Not shown: 998 filtered ports PORT STATE SERVICE 80/tcp open http 443/tcp open https Nmap done: 1 IP address (1 host up) scanned in 19.38 seconds
Step 7: Check all the Available Options
You can check all the command line options available with nmap command using nmap --help command as shown below.
[root@localhost ~]# nmap --help
Nmap 6.40 ( http://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 8: Uninstall Nmap
Once you are done with nmap, you can also choose to uninstall it from your System by using yum remove nmap command as shown below. Similarly, if you have dnf utility available then you need to use dnf remove nmap command to remove the package from your System.
NOTE:
issabel-endpoint dependent package along with the nmap package. Since I don't use this dependent package so I will remove it but make sure you should not end up in removing any active packages.[root@localhost ~]# yum remove nmap Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package nmap.x86_64 2:6.40-19.el7 will be erased --> Processing Dependency: nmap for package: issabel-endpointconfig2-4.0.0-3.noarch --> Running transaction check ---> Package issabel-endpointconfig2.noarch 0:4.0.0-3 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Removing: nmap x86_64 2:6.40-19.el7 @base 16 M Removing for dependencies: issabel-endpointconfig2 noarch 4.0.0-3 @issabel-updates 5.1 M Transaction Summary ======================================================================================================= Remove 1 Package (+1 Dependent package) Installed size: 21 M Is this ok [y/N]: Y .......................................................