{"id":1022,"date":"2021-03-29T12:08:29","date_gmt":"2021-03-29T10:08:29","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=1022"},"modified":"2022-10-12T09:44:08","modified_gmt":"2022-10-12T07:44:08","slug":"how-to-check-port-used-in-our-computer","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2021\/03\/29\/how-to-check-port-used-in-our-computer\/","title":{"rendered":"How to check port used in our Computer."},"content":{"rendered":"\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Linux <\/span><\/h4>\n\n\n\n<p>To check the listening ports and applications on Linux:<\/p>\n\n\n\n<ol><li>Open a terminal application i.e. shell prompt.<\/li><li>Run any one of the following command on Linux to see open ports:<\/li><\/ol>\n\n\n\n<h6><span class=\"has-inline-color has-vivid-red-color\"> # Variante 1<\/span><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lsof -i -P -n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/www.cyberciti.biz\/media\/new\/faq\/2016\/11\/lsof-outputs.png\" alt=\"Fig.01: Check the listening ports and applications with lsof command\" width=\"835\" height=\"72\"\/><\/figure>\n\n\n\n<p>Consider the following line from above outputs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sshd    85379     root    3u  IPv4 0xffff80000039e000      0t0  TCP 10.86.128.138:22 (LISTEN)<\/code><\/pre>\n\n\n\n<ul><li><strong>sshd<\/strong>&nbsp;is the name of the application.<\/li><li><kbd><strong>10.86.128.138<\/strong><\/kbd>&nbsp;is the IP address to which sshd application bind to (LISTEN)<\/li><li><kbd><strong>22<\/strong><\/kbd>&nbsp;is the TCP port that is being used (LISTEN)<\/li><li><kbd><strong>85379<\/strong><\/kbd>&nbsp;is the process ID of the sshd process<\/li><\/ul>\n\n\n\n<h6><span class=\"has-inline-color has-vivid-red-color\"># Variante 2<\/span><\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ss -tulwn<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16-1024x331.png\" alt=\"\" class=\"wp-image-1024\" width=\"1228\" height=\"396\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16-1024x331.png 1024w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16-300x97.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16-768x248.png 768w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16-1536x496.png 1536w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/03\/image-16.png 1835w\" sizes=\"(max-width: 1228px) 100vw, 1228px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Where ss command options are as follows:<\/p>\n\n\n\n<ul><li><kbd><strong>-t<\/strong><\/kbd>&nbsp;: Show only TCP sockets on Linux<\/li><li><kbd><strong>-u<\/strong><\/kbd>&nbsp;: Display only UDP sockets on Linux<\/li><li><kbd><strong>-l<\/strong><\/kbd>&nbsp;: Show listening sockets. For example, TCP port 22 is opened by SSHD server.<\/li><li><kbd><strong>-p<\/strong><\/kbd>&nbsp;: List process name that opened sockets<\/li><li><kbd><strong>-n<\/strong><\/kbd>&nbsp;: Don\u2019t resolve service names i.e. don\u2019t use DNS<\/li><\/ul>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Windows<\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>netstat -a <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>PS-1: <\/strong><em><span class=\"has-inline-color has-luminous-vivid-orange-color\">To list any process listening to the particular port, for example 8080, in Linux :<\/span><\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsof -i:8080<\/code><\/pre>\n\n\n\n<p><strong>PS-2: <\/strong><span class=\"has-inline-color has-luminous-vivid-orange-color\">To kill a process listening on a particular port, for example 8080 (in Linux):<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -9 $(lsof -t -i:8080)<\/code><\/pre>\n\n\n\n<p>PS: <code>-9<\/code>&nbsp;corresponds to the&nbsp;<code>SIGKILL - terminate immediately\/hard kill<\/code>. It implies the process will be killed forcefully.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5>Reference :<\/h5>\n\n\n\n<p><a href=\"https:\/\/www.cyberciti.biz\/\">https:\/\/www.cyberciti.biz\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux To check the listening ports and applications on Linux: Open a terminal application i.e. shell prompt. Run any one of the following command on Linux to see open ports: # Variante 1 Consider the following line from above outputs: sshd&nbsp;is the name of the application. 10.86.128.138&nbsp;is the IP address to which sshd application bind [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,169],"tags":[172,93,270,269,272,271],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1022"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":4,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"predecessor-version":[{"id":2282,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1022\/revisions\/2282"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}