nmap Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The nmap command in Linux is a flexible, powerful, and indispensable tool used for network discovery and security auditing. Short for Network Mapper, nmap is employed by network administrators across the globe to explore networks, perform security scans, detect open ports, and so much more.

Syntax of nmap Command in Linux

The basic syntax of the nmap command in Linux is as follows:

Where:

  • [Scan Type]: This part denotes the type of scan you want to perform. Different types of scans include SYN scan (-sS), TCP scan (-sT), and UDP scan (-sU), among others.
  • [Options]: These are additional parameters that modify the behavior of the nmap command.
  • {target specification}: This is the hostname, IP address, or range of IPs you want to scan.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in nmap Command in Linux

  1. -p: This option specifies the port range to be scanned.

    For example -

    Output:

    This command scans the IP address 192.168.0.1 on ports 22, 80, and 443. The output shows that ports 22 and 443 are open, and 80 is closed.

  2. -sV: This option enables version detection.

    For example -

    Output:

    This command detects services and their versions running on open ports.

  3. -O: This option enables OS detection.

    For example -

    Output:

    This command tries to determine the operating system of the host 192.168.0.1.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Scanning a single host:

    Output:

    Explanation: This command performs a basic scan of the host 192.168.0.1. The output shows the open ports and their services.

  • Scanning multiple hosts:

    Output:

    Explanation: This command scans multiple hosts (192.168.0.1 and 192.168.0.2) and provides individual reports for each.

Tips

  • Always use nmap in a legal and ethical manner. Scanning networks without permission is illegal and unethical.

  • Use the '-v' flag for verbose output, helpful in understanding what's happening during the scan.

  • Utilize '-oN' to save the scan output to a file.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of nmap Command in Linux

  • Ping sweep to discover hosts in a network:

    Output:

    Explanation: This command performs a ping sweep in the 192.168.0.1/24 subnet, identifying hosts that are up.

  • Script scanning using the Nmap Scripting Engine (NSE):

    Output:

    Explanation: This command runs a script 'http-title' from the NSE that fetches the title of the web page running on the target host.

  • Stealth scanning using SYN scan:

    Output:

    Explanation: This command performs a stealthy SYN scan, which is less likely to be logged than a standard scan.

Conclusion

  • The nmap command in Linux is a versatile tool for network exploration and security auditing.

  • It offers a variety of features, from basic scanning and version detection to advanced uses like OS detection and scripting.

  • While powerful, it should always be used responsibly and ethically, respecting network permissions.