{"id":21017,"date":"2023-09-30T11:21:30","date_gmt":"2023-09-30T11:21:30","guid":{"rendered":"https:\/\/linuxways.net\/?p=21017"},"modified":"2023-09-30T11:21:30","modified_gmt":"2023-09-30T11:21:30","slug":"how-do-i-check-if-port-80-and-443-are-open-linux-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/linux-commands\/how-do-i-check-if-port-80-and-443-are-open-linux-ubuntu\/","title":{"rendered":"How do I check if Port 80 and 443 are Open Linux\/Ubuntu?"},"content":{"rendered":"<p>It is essential to know the status of Ports as it leads to the Proper Functioning of Applications, and Remote Access as well. Finding out Open Ports is among the crucial concerns of a System Administrator as leaving them unchecked will lead to potential security concerns. Port 443 is used for protected Web Browsing as it transfers data over a protected network whereas Port 80 transfers the Data in Plain text.<\/p>\n<p>This article explains the different methodologies to check if Port 80 or Port 443 is open in Linux\/Ubuntu.<\/p>\n<h2><strong>How Do I check if Port 80 and 443 are Open in Linux\/Ubuntu?<\/strong><\/h2>\n<p>To check if the port is open for remote connectivity of Ubuntu, several methods can be used. Some of the methods to check if a port is open are:<\/p>\n<ul>\n<li>\u201cnetstat\u201d Method<\/li>\n<li>\u201css\u201d command Method<\/li>\n<li>\u201clsof\u201d command Method<\/li>\n<li>\u201cnetcat\u201d Method<\/li>\n<li>\u201cnmap\u201d Method<\/li>\n<li>\u201cPowerShell\u201d Method<\/li>\n<\/ul>\n<h2><strong>Enabling Port 443 (Prerequisite)<\/strong><\/h2>\n<p>Before diving into the process of checking the status of ports, let\u2019s have a look at how we can enable Port 443 to \u201cLISTEN\u201d. Port 443 is used by web servers in the background and is disabled by default. To enable the port, we have to enable it from the configuration files of any of the running services like Apache or Node. To enable Port 443, first, redirect to the Apache2 directory using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">cd<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apache2<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"753\" height=\"44\" class=\"wp-image-21018\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-1.png 753w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-1-300x18.png 300w\" sizes=\"auto, (max-width: 753px) 100vw, 753px\" \/><\/p>\n<p>List the Apache2 directory files and look for the \u201cports.conf\u201d file using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"88\" class=\"wp-image-21019\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-2.png 731w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-2-300x36.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>Open the \u201cports.conf\u201d file using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> ports.conf<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"754\" height=\"86\" class=\"wp-image-21020\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-3.png 754w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-3-300x34.png 300w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><\/p>\n<p>This will open the text editor for the \u201cports.conf\u201d file and in our case, only Port 80 is Opened and actively Listening:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"745\" height=\"480\" class=\"wp-image-21021\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-4.png 745w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-4-300x193.png 300w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><\/p>\n<p>Edit the file and add the line below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">Listen <span class=\"nu0\">443<\/span><\/div><\/div>\n<p>Save the file by pressing \u201cctrl+O\u201d and exit using \u201cctrl+X\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"753\" height=\"485\" class=\"wp-image-21022\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-5.png 753w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-5-300x193.png 300w\" sizes=\"auto, (max-width: 753px) 100vw, 753px\" \/><\/p>\n<p>Now your Apache2 will use Port 443 for active listening.<\/p>\n<p>The detailed procedure for checking the status of Port 80 and 443 using all the mentioned methods is explained below.<\/p>\n<h2><strong>Method 1: Checking Port 80 &amp; 443 Status Using \u201cnetstat\u201d Command<\/strong><\/h2>\n<p>The <strong>netstat <\/strong>command is used for configuring the network connectivity. To use netstat, install the \u201c<strong>net-tools<\/strong>\u201d package first using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt update <span class=\"re5\">-y<\/span> <span class=\"sy0\">&amp;&amp;<\/span> apt <span class=\"kw2\">install<\/span> net-tools <span class=\"re5\">-y<\/span><\/div><\/div>\n<p>It will take some time to download and install the packages.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"901\" height=\"195\" class=\"wp-image-21023\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-6.png 901w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-6-300x65.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-6-768x166.png 768w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><\/p>\n<p>Once downloaded, use the command below to get all the port details:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">netstat<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"416\" class=\"wp-image-21024\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-7.png 887w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-7-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-7-768x360.png 768w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/p>\n<p>To get the Port 80 and only the one with LISTEN status, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">netstat<\/span> <span class=\"re5\">-tulpn<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">80<\/span><\/div><\/div>\n<p>Here, the \u201c<strong>-tulpn<\/strong>\u201d flag displays all the listening ports. The \u201c<strong>grep<\/strong>\u201d is used to filter and in this case, it will filter the word \u201cLISTEN\u201d as well as display only the items matching \u201c<strong>:80<\/strong>\u201d which is the port number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"78\" class=\"wp-image-21025\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-8.png 891w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-8-300x26.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-8-768x67.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/p>\n<p>The output shows that Port 80 is Listening meaning it is Open.<\/p>\n<p>Now to get Port 443 and only the one with LISTEN status, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">netstat<\/span> <span class=\"re5\">-tulpn<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">443<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"125\" class=\"wp-image-21026\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-9.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-9-300x51.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<h2><strong>Method 2: Checking Port 80 &amp; 443 Status Using \u201css\u201d Command<\/strong><\/h2>\n<p>The \u2018\u2019ss\u201d command is used to display the socket statistics. The \u201css\u201d command can \u201cList all Sockets\u201d, \u201cList Listening Sockets\u201d, \u201cDisplay TCP and UDP Sockets\u201d, and can also display \u201cEstablished Connections\u201d. It is used as an alternative to the \u201cnetstat\u201d command as it is simple to use and is faster than the \u201cnetstat\u201d command. To use the \u201css\u201d command, use the command below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">ss <span class=\"re5\">-tulpn<\/span><\/div><\/div>\n<p>This will display all the Listening Ports:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"894\" height=\"308\" class=\"wp-image-21027\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-10.png 894w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-10-300x103.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-10-768x265.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/p>\n<p>To display only Port 80, use the \u201css\u201d command as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">ss <span class=\"re5\">-tulpn<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">80<\/span><\/div><\/div>\n<p>The \u201c<strong>-tulpn<\/strong>\u201d flag will display all the listening ports. The \u201c<strong>grep<\/strong>\u201d will filter the word \u201cLISTEN\u201d as well as display only the connections matching \u201c<strong>:80<\/strong>\u201d which is the port number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"892\" height=\"68\" class=\"wp-image-21028\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-11.png 892w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-11-300x23.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-11-768x59.png 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/p>\n<p>The output above shows Port 80 is Open and is Listening.<\/p>\n<p>Similarly, to find if the Port 443 is open, the command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">ss <span class=\"re5\">-tulpn<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">443<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"73\" class=\"wp-image-21029\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-12.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-12-300x30.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<h2><strong>Method 3: Checking Port 80 &amp; 443 Status Using \u201clsof\u201d Command<\/strong><\/h2>\n<p>The \u201clsof\u201d command means \u201cList Open Files\u201d and lists information about files currently opened by a process. Although it is used to list opened and in-process files, it can also be used to display information about network connections such as showing the open sockets. Use \u201clsof\u201d by running the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> lsof <span class=\"re5\">-i<\/span> <span class=\"re5\">-n<\/span> <span class=\"re5\">-P<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">80<\/span><\/div><\/div>\n<p>Here the flag \u201c-P\u201d shows the port number, \u201c-i\u201d shows the open sockets, and \u201c-n\u201d is responsible for showing the IP Address instead of remote hostnames:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"894\" height=\"150\" class=\"wp-image-21030\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-13.png 894w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-13-300x50.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-13-768x129.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/p>\n<p>Here, the \u201c<strong>4u<\/strong>\u201d indicates file descriptors for IPv6, \u201c<strong>0t0<\/strong>\u201d shows the status of Port 80 which is currently in LISTEN State, and \u201c<strong>31398<\/strong>\u201d indicates the process id.<\/p>\n<p>To find out about Port 443, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> lsof <span class=\"re5\">-i<\/span> <span class=\"re5\">-P<\/span> <span class=\"re5\">-n<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> LISTEN <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> :<span class=\"nu0\">443<\/span><\/div><\/div>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"168\" class=\"wp-image-21031\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-14.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-14-300x70.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h2><strong>Method 4: Checking Port 80 &amp; 443 Status Using \u201cnetcat\u201d Method<\/strong><\/h2>\n<p>The \u201cnetcat\u201d is another method to check the status of a Port. It is used to analyze network hosts by connecting to a TCP port. To use netcat, use the command given below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nc <span class=\"re5\">-zv<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span><span class=\"kw2\">hostname<\/span><span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>port<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> number<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<p>Here, the \u201c-z\u201d scans for open ports, \u201cnc\u201d is the command for netcat, and \u201c-v\u201d indicates whether the port is open or closed. As we want to check the status of Port 80 on host \u201ctaha khan\u201d, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nc <span class=\"re5\">-zv<\/span> tahakhan <span class=\"nu0\">80<\/span><\/div><\/div>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"65\" class=\"wp-image-21032\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-15.png 730w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-15-300x27.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/p>\n<p>Similarly, for Port 443, we will use:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nc <span class=\"re5\">-zv<\/span> tahakhan <span class=\"nu0\">443<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"70\" class=\"wp-image-21033\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-16.png 741w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-16-300x28.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/p>\n<h2><strong>Method 5: Checking Port 80 &amp; 443 Status Using \u201cnmap\u201d Method<\/strong><\/h2>\n<p>The \u201c<strong>nmap<\/strong>\u201d method is used to check the Port Status on a <strong>Host Machine<\/strong>. The \u201cnmap\u201d command is used as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nmap<\/span> <span class=\"re5\">-p<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>port<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> number<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>host<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> IP<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>Here, the \u201c-p\u201d flag is used to specify the Port.<\/p>\n<p>Before using \u201cnmap\u201d ensure it is installed. If not, use the following command to install:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> <span class=\"kw2\">nmap<\/span> <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"826\" height=\"432\" class=\"wp-image-21034\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-17.png 826w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-17-300x157.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-17-768x402.png 768w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/p>\n<p>To use the \u201cnmap\u201d command you need to know the IP Address of the Host Machine. Consider an example in my case where the Host System name is \u201c<strong>tahakhan<\/strong>\u201d and the Client is \u201cubuntu1\u201d. The Host Machine has IP Address \u201c<strong>192.168.184.130<\/strong>\u201d. To check the status of Port 80, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nmap<\/span> <span class=\"re5\">-p<\/span> <span class=\"nu0\">80<\/span> 192.168.184.130<\/div><\/div>\n<p>The status of Port 80 of our Host Machine will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"223\" class=\"wp-image-21035\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-18.png 815w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-18-300x82.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-18-768x210.png 768w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Port 80 shows the State as Open meaning it is Listening. Similarly, to find the status of Port 443 of our Host Machine, execute the \u201cnmap\u201d command as shown below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nmap<\/span> <span class=\"re5\">-p<\/span> <span class=\"nu0\">443<\/span> 192.168.184.130<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"223\" class=\"wp-image-21036\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-19.png 820w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-19-300x82.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-19-768x209.png 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/p>\n<p>Port 443 is open as shown in the State status.<\/p>\n<h2><strong>Method 6: Checking Port 80 &amp; 443 Status Using \u201cPowerShell\u201d <\/strong><\/h2>\n<p>With PowerShell in Ubuntu, you can use the TcpClient class to check the open ports. Before checking the connections and open ports, install PowerShell in Ubuntu using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> snap <span class=\"kw2\">install<\/span> powershell <span class=\"re5\">--classic<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"59\" class=\"wp-image-21037\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-20.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-20.png 759w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-20-300x23.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><\/p>\n<p>Launch it using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">pwsh<\/div><\/div>\n<p>The command line will change indicating PowerShell is initialized:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"64\" class=\"wp-image-21038\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-21.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-21.png 750w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-21-300x26.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>Create a file now where a script will be added. In our case, we create a file using the \u201cnano\u201d editor:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nano<\/span> Port.ps1<\/div><\/div>\n<p>The \u201c.ps1\u201d extension indicates it is a PowerShell Script.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"60\" class=\"wp-image-21039\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-22.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-22.png 741w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-22-300x24.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/p>\n<p>The text editor will open, and add the below script inside the \u201cPort.ps1\u201d file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;height:100%;\"><div class=\"bash codecolorer\"><span class=\"br0\">&#91;<\/span>CmdletBinding<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>OutputType<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#91;<\/span>System.Management.Automation.PSCustomObject<span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\nparam <span class=\"br0\">&#40;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>Parameter<span class=\"br0\">&#40;<\/span>Mandatory<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>string<span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#93;<\/span><span class=\"re1\">$SystemName<\/span>,<br \/>\n<span class=\"br0\">&#91;<\/span>Parameter<span class=\"br0\">&#40;<\/span>Mandatory<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>int<span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#93;<\/span><span class=\"re1\">$Port<\/span>,<br \/>\n<span class=\"br0\">&#91;<\/span>Parameter<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>int<span class=\"br0\">&#93;<\/span><span class=\"re1\">$TcpTimeout<\/span> = <span class=\"nu0\">1000<\/span><br \/>\n<span class=\"br0\">&#41;<\/span><br \/>\nbegin <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re1\">$Protocol<\/span> = <span class=\"st_h\">'TCP'<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\nprocess <span class=\"br0\">&#123;<\/span><br \/>\nforeach <span class=\"br0\">&#40;<\/span><span class=\"re1\">$System<\/span> <span class=\"kw1\">in<\/span> <span class=\"re1\">$SystemName<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\nforeach <span class=\"br0\">&#40;<\/span><span class=\"re1\">$Portx<\/span> <span class=\"kw1\">in<\/span> <span class=\"re1\">$Port<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re1\">$Output<\/span> = <span class=\"sy0\">@<\/span><span class=\"br0\">&#123;<\/span> <span class=\"st_h\">'Computer Name'<\/span> = <span class=\"re1\">$System<\/span>; <span class=\"st_h\">'Port'<\/span> = <span class=\"re1\">$Portx<\/span>; <span class=\"st_h\">'Protocol'<\/span> = <span class=\"re1\">$Protocol<\/span>; <span class=\"st_h\">'Result'<\/span> = <span class=\"st_h\">''<\/span> <span class=\"br0\">&#125;<\/span><br \/>\nWrite-Verbose <span class=\"st0\">&quot;<span class=\"es4\">$($MyInvocation.MyCommand.Name)<\/span> - Beginning port test on '<span class=\"es2\">$System<\/span>' on port '<span class=\"es2\">$Protocol<\/span>&lt;code&gt;:<span class=\"es2\">$Portx<\/span>'&quot;<\/span><br \/>\n<br \/>\n<span class=\"re1\">$TClient<\/span> = New-Object System.Net.Sockets.TcpClient<br \/>\n<span class=\"re1\">$Connect<\/span> = <span class=\"re1\">$TClient<\/span>.BeginConnect<span class=\"br0\">&#40;<\/span><span class=\"re1\">$System<\/span>, <span class=\"re1\">$Portx<\/span>, <span class=\"re1\">$null<\/span>, <span class=\"re1\">$null<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"re1\">$W<\/span> = <span class=\"re1\">$Connect<\/span>.AsyncWaitHandle.WaitOne<span class=\"br0\">&#40;<\/span><span class=\"re1\">$TcpTimeout<\/span>, <span class=\"re1\">$false<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"sy0\">!<\/span><span class=\"re1\">$W<\/span> <span class=\"re5\">-or<\/span> <span class=\"sy0\">!<\/span><span class=\"br0\">&#40;<\/span><span class=\"re1\">$TClient<\/span>.Connected<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re1\">$TClient<\/span>.Close<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\nWrite-Verbose <span class=\"st0\">&quot;<span class=\"es4\">$($MyInvocation.MyCommand.Name)<\/span> - '<span class=\"es2\">$System<\/span>' failed port test on port '<span class=\"es2\">$Protocol<\/span>&lt;\/code&gt;:<span class=\"es2\">$Portx<\/span>'&quot;<\/span><br \/>\n<span class=\"re1\">$Output<\/span>.Result = <span class=\"re1\">$false<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re1\">$TClient<\/span>.EndConnect<span class=\"br0\">&#40;<\/span><span class=\"re1\">$Connect<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"re1\">$TClient<\/span>.Close<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\nWrite-Verbose <span class=\"st0\">&quot;<span class=\"es4\">$($MyInvocation.MyCommand.Name)<\/span> - '<span class=\"es2\">$System<\/span>' passed port test on port '<span class=\"es2\">$Protocol<\/span>&lt;code&gt;:<span class=\"es2\">$Portx<\/span>'&quot;<\/span><br \/>\n<span class=\"re1\">$Output<\/span>.Result = <span class=\"re1\">$true<\/span><br \/>\n<span class=\"re1\">$TClient<\/span>.Close<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"re1\">$TClient<\/span>.Dispose<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#91;<\/span>pscustomobject<span class=\"br0\">&#93;<\/span><span class=\"re1\">$Output<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Save the file using \u201cctrl+O\u201d and exit the text editor. To test Ports, run the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">.<span class=\"sy0\">\/&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>filename<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span>.ps1 <span class=\"re5\">-ComputerName<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span><span class=\"kw2\">hostname<\/span><span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re5\">-Port<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>portnumber<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>portnumber<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;<\/span>...<\/div><\/div>\n<p>In our case, Port 80 and Port 443 have to be checked, so specify \u201c-Port 80, 443\u201d<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">.<span class=\"sy0\">\/<\/span>Port.ps1 <span class=\"re5\">-ComputerName<\/span> tahakhan <span class=\"re5\">-Port<\/span> <span class=\"nu0\">80<\/span>, <span class=\"nu0\">443<\/span><\/div><\/div>\n<p>Executing the command displays the status of both Ports.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"132\" class=\"wp-image-21040\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-23.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-23.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21017-23-300x54.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<p>The Result \u201cTrue\u201d means that both Ports are open.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Check the status of Port 80 and 443 on Ubuntu\/Linux using \u201cnetstat\u201d, \u201cnetcat\u201d, \u201cnmap\u201d and various other methodologies. Ports in Ubuntu are primarily used for network communication and configuration. As many functions rely on specific ports to function, it is essential to know the status of Ports. Port configuration can lead to the Proper Functioning of Applications, and Remote Access as well. This article explained various methodologies involving different steps to check the status of specific Ports on a Host System.<\/p>","protected":false},"excerpt":{"rendered":"<p>Check the status of Port 80 and 443 using \u201cnetstat\u201d, \u201cnetcat\u201d, \u201cnmap\u201d and various other methodologies. Check the Port status of a Host System remotely.<\/p>","protected":false},"author":110,"featured_media":21442,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049],"tags":[],"class_list":["post-21017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21017"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21017\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21442"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}