{"id":20885,"date":"2021-04-03T23:19:48","date_gmt":"2021-04-03T17:49:48","guid":{"rendered":"https:\/\/valeurbit.com\/blog\/?p=20885"},"modified":"2021-04-03T23:19:51","modified_gmt":"2021-04-03T17:49:51","slug":"nmap-commands-for-linux-systems","status":"publish","type":"post","link":"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/","title":{"rendered":"Nmap commands for Linux systems"},"content":{"rendered":"\n<p><strong>Nmap<\/strong>\u00a0is short for\u00a0<strong>Network\u00a0Mapper<\/strong>\u00a0.\u00a0It is an open source security tool for network exploration, security scanning, and auditing.\u00a0However, the\u00a0<strong>nmap<\/strong>\u00a0command\u00a0comes with a lot of options that make the utility more advanced, but also more difficult for newbies.\u00a0The purpose of this article is to introduce you to the\u00a0<strong>nmap<\/strong>\u00a0command line tool\u00a0for scanning a host and network to identify possible vulnerabilities.\u00a0You will also learn how to use\u00a0<strong>Nmap<\/strong>\u00a0for offensive and defensive purposes.\u00a0Let&#8217;s see some common examples of\u00a0<strong>nmap<\/strong>\u00a0commands\u00a0.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is Nmap and what is it used for?<\/h4>\n\n\n\n<p>Information from the instruction manual page:<\/p>\n\n\n\n<p><strong>Nmap<\/strong>&nbsp;(&#8220;Network Mapper&#8221;) is an open source network exploration and security audit tool.&nbsp;It was designed to quickly scan large networks.&nbsp;<strong>Nmap<\/strong>&nbsp;uses raw&nbsp;<strong>IP<\/strong>&nbsp;packets to determine what hosts are available on the network, what services (application name and version) these hosts offer, what operating systems (and OS versions) they run on, what type of packet filters \/ firewalls are in use, and dozens of other characteristics.&nbsp;Although&nbsp;<strong>Nmap is<\/strong>&nbsp;commonly used for security auditing, many system and network administrators find it useful for mundane tasks such as network inventory, managing service update schedules, and monitoring host or service uptime.<\/p>\n\n\n\n<p><strong>Nmap for Linux systems<\/strong>&nbsp;was written by&nbsp;<strong>Gordon&nbsp;<\/strong><strong>Lyon<\/strong>&nbsp;.&nbsp;This tool can easily answer the following questions:<\/p>\n\n\n\n<ul><li>What computers are on the local network?<\/li><li>What\u00a0<strong>IP<\/strong>\u00a0addresses work on the local network?<\/li><li>What is the operating system on your target machine?<\/li><li>What ports are open on the machine you just scanned?<\/li><li>Is the system infected with malware or virus?<\/li><li>Search for unauthorized servers or network services on your network.<\/li><li>Find and remove computers that do not meet the minimum security level.<\/li><\/ul>\n\n\n\n<p>In this article we will try to tell you a little about this utility and give examples of commands for system administrators.<strong>Installing the nmap application<\/strong><\/p>\n\n\n\n<p>On&nbsp;<strong>Debian \/ Ubuntu \/ Linux Min<\/strong>&nbsp;t systems, do the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get install nmap<\/pre>\n\n\n\n<p>On&nbsp;<strong>RedHat \/ CentOS \/ Fedora system,<\/strong>&nbsp;you need to do the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install nmap<\/pre>\n\n\n\n<p>On&nbsp;<strong>OpenBSD,<\/strong>&nbsp;you need to do the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pkg_add -v nmap<\/pre>\n\n\n\n<p>We will not describe the entire syntax of this utility, since it is quite large, and there is always&nbsp;<strong>nmap \u2013help&nbsp;<\/strong>or&nbsp;<strong>man nmap&nbsp;<\/strong>at hand&nbsp;, and we will give examples of the most common operations with a small description.<\/p>\n\n\n\n<p>Most of nmap&#8217;s operations require&nbsp;<strong>root authority<\/strong>&nbsp;.&nbsp;When running nmap as a normal user, most of the functionality will be unavailable.<\/p>\n\n\n\n<p><strong>Scan a single host or IP address<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap 192.168.1.1 \n\nnmap valeurbit.com \n\n## -v - use \"detailed report\" mode ## \n\nnmap -v valeurbit.com<\/pre>\n\n\n\n<p><strong>Scan multiple IP addresses or subnet<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap 192.168.1.1 192.168.1.2 192.168.1.3\n## IP address range ## <br>\nnmap 192.168.1.1-20 <br>\nnmap 192.168.1.1,2,3 <br>\n## Scan entire subnet ## <br>\nnmap 192.168.1.0\/24 <br>\n## Ping address range ## <br>\nnmap -sP 192.168.0.100-254<\/pre>\n\n\n\n<p><strong>-sP<\/strong>&nbsp;&#8211; ping- &#8220;scan&#8221;<strong>Determine the operating system of the host being scanned<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap -O 192.168.0.1-255<\/pre>\n\n\n\n<p><strong>-O<\/strong>&nbsp;&#8211; this option allows you to determine the operating system of the scanned host using the TCP \/ IP stack fingerprint method<strong>Service scan<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap -sV valeurbit.com<\/pre>\n\n\n\n<p><strong>-sV<\/strong>&nbsp;&#8211; enable the mode of determining the versions of the services to which the scanned ports are assigned.<strong>Read the list of hosts \/ networks from the file<\/strong><\/p>\n\n\n\n<p>Sometimes there is a need to scan a large number of hosts and networks and, for convenience, they can be listed in a text document and then used.<\/p>\n\n\n\n<p>Let&#8217;s create a&nbsp;<strong>net.text<\/strong>&nbsp;file&nbsp;<strong>with the<\/strong>&nbsp;following content:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">192.168.1.0\/24\n192.168.1.1\/24\n192.168.1.2\/24<\/pre>\n\n\n\n<p>Now let&#8217;s scan them:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap -iL net.txt<\/pre>\n\n\n\n<p><strong>-iL &lt;file_name&gt;<\/strong>&nbsp;&#8211; reads the description of target hosts from a text file<strong>Writing the scan result to a text file<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap 192.168.0.1&gt; output.txt\nnmap -oN \/ usr \/ filename 192.168.0.1\nnmap -oN output.txt 192.168.0.1<\/pre>\n\n\n\n<p><strong>-oN &lt;file_name&gt;<\/strong>&nbsp;&#8211; writes the scan results to the specified file in a user-friendly form.<strong>Scan the network and find out which servers and devices are up and running (Host is up)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap -sP 192.168.0.0\/24<\/pre>\n\n\n\n<p><strong>Show host and routes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap \u2013iflist<\/pre>\n\n\n\n<p><strong>Scan specific ports<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">map -p [port] hostName\n\n## Scan TCP port 80 ##\nnmap -p T: 80 192.168.1.1<br>\n\n## Scan UDP port 19 ##\nnmap -p U: 19 192.168.1.1<br>\n\n## Scan multiple ports ##\nnmap -p 80,443 192.168.1.1<br>\n\n## Scan port range ##\nnmap -p 80-200 192.168.1.1<br>\n\n## Combined scan ##\nnmap -p U: 53,111,137, T: 21-25,80,139,8080 192.168.1.1<br>\n\n## Scan all ports ##\nnmap -p \"*\" 192.168.1.1<\/pre>\n\n\n\n<p><strong>Nmap<\/strong>&nbsp;recognizes six port states:<br><strong>open<\/strong>&nbsp;&#8211; open<br><strong>closed<\/strong>&nbsp;&#8211; closed<br><strong>filtered<\/strong>&nbsp;&#8211; the port is not available, most likely filtered by the firewall<br><strong>unfiltered<\/strong>&nbsp;&#8211; the port is available, but the state could not be determined<br><strong>open | filtered<\/strong>&nbsp;&#8211; open or filtered by the firewall<br><strong>closed | filtered<\/strong>&nbsp;&#8211; closed or filtered by the firewall<br><strong>Scan hosts for UDP or TCP services<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nmap -sU 192.168.0.1\nnmap -sT 192.168.0.1<\/pre>\n\n\n\n<p><strong>-sU<\/strong>&nbsp;&#8211; scan UDP ports<\/p>\n\n\n\n<p><strong>-sT<\/strong>&nbsp;is a generic TCP port scan method&nbsp;If you find errors or inconsistencies in the article, we will be grateful if you write to us about them in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nmap\u00a0is short for\u00a0Network\u00a0Mapper\u00a0.\u00a0It is an open source security tool for network exploration, security scanning, and auditing.\u00a0However, the\u00a0nmap\u00a0command\u00a0comes with a lot of options that make the utility more advanced, but also more difficult for newbies.\u00a0The purpose of this article is to introduce you to the\u00a0nmap\u00a0command line tool\u00a0for scanning a host and network to identify possible vulnerabilities.\u00a0You&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nmap commands for Linux systems | ValeurBit Infosec<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nmap commands for Linux systems | ValeurBit Infosec\" \/>\n<meta property=\"og:description\" content=\"Nmap\u00a0is short for\u00a0Network\u00a0Mapper\u00a0.\u00a0It is an open source security tool for network exploration, security scanning, and auditing.\u00a0However, the\u00a0nmap\u00a0command\u00a0comes with a lot of options that make the utility more advanced, but also more difficult for newbies.\u00a0The purpose of this article is to introduce you to the\u00a0nmap\u00a0command line tool\u00a0for scanning a host and network to identify possible vulnerabilities.\u00a0You...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/\" \/>\n<meta property=\"og:site_name\" content=\"ValeurBit Infosec\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/valeurbitinfo\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-03T17:49:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-03T17:49:51+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@valeurbit\" \/>\n<meta name=\"twitter:site\" content=\"@valeurbit\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\",\"name\":\"Valeurbit Infosec\",\"url\":\"https:\/\/valeurbit.com\/blog\/\",\"sameAs\":[\"https:\/\/www.facebook.com\/valeurbitinfo\/\",\"https:\/\/www.instagram.com\/valeurbit\",\"https:\/\/www.linkedin.com\/company\/valeurbit-infosec\/\",\"https:\/\/twitter.com\/valeurbit\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/valeurbit.com\/blog\/wp-content\/uploads\/2021\/02\/Valeurbit-new-logo-center.png\",\"contentUrl\":\"https:\/\/valeurbit.com\/blog\/wp-content\/uploads\/2021\/02\/Valeurbit-new-logo-center.png\",\"width\":1080,\"height\":512,\"caption\":\"Valeurbit Infosec\"},\"image\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#website\",\"url\":\"https:\/\/valeurbit.com\/blog\/\",\"name\":\"ValeurBit Infosec\",\"description\":\"Cyber Security Company\",\"publisher\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/valeurbit.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#webpage\",\"url\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/\",\"name\":\"Nmap commands for Linux systems | ValeurBit Infosec\",\"isPartOf\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#website\"},\"datePublished\":\"2021-04-03T17:49:48+00:00\",\"dateModified\":\"2021-04-03T17:49:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/valeurbit.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nmap commands for Linux systems\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#webpage\"},\"author\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#\/schema\/person\/df20c1cd317765fa8677a3056caeccfa\"},\"headline\":\"Nmap commands for Linux systems\",\"datePublished\":\"2021-04-03T17:49:48+00:00\",\"dateModified\":\"2021-04-03T17:49:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/nmap-commands-for-linux-systems\/#webpage\"},\"wordCount\":728,\"publisher\":{\"@id\":\"https:\/\/valeurbit.com\/blog\/#organization\"},\"articleSection\":[\"Valeurbit\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/valeurbit.com\/blog\/#\/schema\/person\/df20c1cd317765fa8677a3056caeccfa\",\"name\":\"ValeurBit\",\"sameAs\":[\"https:\/\/valeurbit.com\/blog\"],\"url\":\"https:\/\/valeurbit.com\/blog\/author\/valeurbit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts\/20885"}],"collection":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/comments?post=20885"}],"version-history":[{"count":0,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/posts\/20885\/revisions"}],"wp:attachment":[{"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/media?parent=20885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/categories?post=20885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/valeurbit.com\/blog\/wp-json\/wp\/v2\/tags?post=20885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}