{"id":12408,"date":"2019-03-26T23:06:19","date_gmt":"2019-03-26T23:06:19","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12408"},"modified":"2019-03-26T23:06:19","modified_gmt":"2019-03-26T23:06:19","slug":"how-to-find-out-list-of-all-open-ports-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/how-to-find-out-list-of-all-open-ports-in-linux\/","title":{"rendered":"How to Find Out List of All Open Ports in Linux"},"content":{"rendered":"<p>In this article, we will briefly talk about ports in computer networking and move to how you can list all open ports in Linux.<\/p>\n<p>In computer networking, and more definitely in software terms, a port is a logical entity which acts as a endpoint of communication to\u00a0<a href=\"https:\/\/www.tecmint.com\/find-process-name-pid-number-linux\/\" target=\"_blank\" rel=\"noopener\">identify a given application or process on an Linux<\/a>\u00a0operating system. It is a 16-bit number (<strong>0<\/strong>\u00a0to\u00a0<strong>65535<\/strong>) which differentiates one application from another on end systems.<\/p>\n<p>The two most popular Internet transport protocols,\u00a0<strong>Transmission Control Protocol<\/strong>\u00a0(<strong>TCP<\/strong>) and the\u00a0<strong>User Datagram Protocol<\/strong>\u00a0(<strong>UDP<\/strong>) and other less known protocols use port numbers for communication sessions (source and destination port numbers in conjunction with the source and destination IP addresses).<\/p>\n<p>In addition, a combination of an IP address, port and protocol such as\u00a0<strong>TCP\/UDP<\/strong>\u00a0is known as a socket, and every service must have a unique socket.<\/p>\n<p>Below are the different categories of ports:<\/p>\n<ol>\n<li><strong>0-1023<\/strong>\u00a0\u2013 the Well Known Ports, also referred to as System Ports.<\/li>\n<li><strong>1024-49151<\/strong>\u00a0\u2013 the Registered Ports, also known as User Ports.<\/li>\n<li><strong>49152-65535<\/strong>\u00a0\u2013 the Dynamic Ports, also referred to as the Private Ports.<\/li>\n<\/ol>\n<p>You can view a list of different applications and port\/protocol combination in\u00a0<code>\/etc\/services<\/code>\u00a0file in Linux using\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>:<\/p>\n<pre>$ cat \/etc\/services \r\nOR\r\n$ cat \/etc\/services | less\r\n<\/pre>\n<div class=\"code-label\">Network Services and Ports<\/div>\n<pre># \/etc\/services:\r\n# $Id: services,v 1.48 2009\/11\/11 14:32:31 ovasik Exp $\r\n#\r\n# Network services, Internet style\r\n# IANA services version: last updated 2009-11-10\r\n#\r\n# Note that it is presently the policy of IANA to assign a single well-known\r\n# port number for both TCP and UDP; hence, most entries here have two entries\r\n# even if the protocol doesn't support UDP operations.\r\n# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports\r\n# are included, only the more common ones.\r\n#\r\n# The latest IANA port assignments can be gotten from\r\n#       http:\/\/www.iana.org\/assignments\/port-numbers\r\n# The Well Known Ports are those from 0 through 1023.\r\n# The Registered Ports are those from 1024 through 49151\r\n# The Dynamic and\/or Private Ports are those from 49152 through 65535\r\n#\r\n# Each line describes one service, and is of the form:\r\n#\r\n# service-name  port\/protocol  [aliases ...]   [# comment]\r\n\r\ntcpmux          1\/tcp                           # TCP port service multiplexer\r\ntcpmux          1\/udp                           # TCP port service multiplexer\r\nrje             5\/tcp                           # Remote Job Entry\r\nrje             5\/udp                           # Remote Job Entry\r\necho            7\/tcp\r\necho            7\/udp\r\ndiscard         9\/tcp           sink null\r\ndiscard         9\/udp           sink null\r\nsystat          11\/tcp          users\r\nsystat          11\/udp          users\r\ndaytime         13\/tcp\r\ndaytime         13\/udp\r\nqotd            17\/tcp          quote\r\nqotd            17\/udp          quote\r\nmsp             18\/tcp                          # message send protocol\r\nmsp             18\/udp                          # message send protocol\r\nchargen         19\/tcp          ttytst source\r\nchargen         19\/udp          ttytst source\r\nftp-data        20\/tcp\r\nftp-data        20\/udp\r\n# 21 is registered to ftp, but also used by fsp\r\nftp             21\/tcp\r\nftp             21\/udp          fsp fspd\r\nssh             22\/tcp                          # The Secure Shell (SSH) Protocol\r\nssh             22\/udp                          # The Secure Shell (SSH) Protocol\r\ntelnet          23\/tcp\r\ntelnet          23\/udp\r\n<\/pre>\n<p>To list all open ports or currently running ports including\u00a0<strong>TCP<\/strong>\u00a0and\u00a0<strong>UDP<\/strong>\u00a0in Linux, we will use\u00a0<a href=\"https:\/\/www.tecmint.com\/20-netstat-commands-for-linux-network-management\/\" target=\"_blank\" rel=\"noopener\">netstat<\/a>, is a powerful tool for monitoring network connections and statistics.<\/p>\n<div class=\"code-label\">List All Network Ports Using Netstat Command<\/div>\n<pre><strong>$ netstat -lntu<\/strong>\r\n\r\nProto Recv-Q Send-Q Local Address               Foreign Address             State      \r\ntcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      \r\ntcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      \r\ntcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      \r\ntcp        0      0 :::22                       :::*                        LISTEN      \r\ntcp        0      0 :::80                       :::*                        LISTEN      \r\ntcp        0      0 :::25                       :::*                        LISTEN      \r\nudp        0      0 0.0.0.0:68                  0.0.0.0:*                               \r\n<\/pre>\n<p>Where,<\/p>\n<ol>\n<li><code>-l<\/code>\u00a0\u2013 prints only listening sockets<\/li>\n<li><code>-n<\/code>\u00a0\u2013 shows port number<\/li>\n<li><code>-t<\/code>\u00a0\u2013 enables listing of tcp ports<\/li>\n<li><code>-u<\/code>\u00a0\u2013 enables listing of udp ports<\/li>\n<\/ol>\n<p>You can also use\u00a0<strong>ss<\/strong>\u00a0command, a well known useful utility for examining sockets in a Linux system. Run the command below to list all your open TCP and UCP ports:<\/p>\n<div class=\"code-label\">List All Network Ports Using ss Command<\/div>\n<pre><strong>$ ss -lntu<\/strong>\r\n\r\nNetid State      Recv-Q Send-Q               Local Address:Port       Peer Address:Port \r\nudp   UNCONN     0      0                    *:68                     *:*     \r\ntcp   LISTEN     0      128                  :::22                    :::*     \r\ntcp   LISTEN     0      128                  *:22                     *:*     \r\ntcp   LISTEN     0      50                   *:3306                   *:*     \r\ntcp   LISTEN     0      128                  :::80                    ::*     \r\ntcp   LISTEN     0      100                  :::25                    :::*     \r\ntcp   LISTEN     0      100                  *:25  \r\n<\/pre>\n<p>Make it a point to read through the man pages of the commands above for more usage information.<\/p>\n<p>In summary, understanding the concept of ports in computer networking is very vital for system and network administrators. You can as well go through this\u00a0<a href=\"https:\/\/www.tecmint.com\/20-netstat-commands-for-linux-network-management\/\" target=\"_blank\" rel=\"noopener\">netstat guide<\/a>\u00a0with simple, precise and well explained examples.<\/p>\n<p>Last but not least, get in touch with us by sharing other methods for listing open ports in Linux or asking a question via the response form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/find-open-ports-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will briefly talk about ports in computer networking and move to how you can list all open ports in Linux. In computer networking, and more definitely in software terms, a port is a logical entity which acts as a endpoint of communication to\u00a0identify a given application or process on an Linux\u00a0operating &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/how-to-find-out-list-of-all-open-ports-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Find Out List of All Open Ports in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12408","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12408"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12408\/revisions"}],"predecessor-version":[{"id":12409,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12408\/revisions\/12409"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}