{"id":13560,"date":"2019-04-03T10:38:46","date_gmt":"2019-04-03T10:38:46","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13560"},"modified":"2019-04-03T10:38:46","modified_gmt":"2019-04-03T10:38:46","slug":"3-ways-to-find-out-which-process-listening-on-a-particular-port","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/3-ways-to-find-out-which-process-listening-on-a-particular-port\/","title":{"rendered":"3 Ways to Find Out Which Process Listening on a Particular Port"},"content":{"rendered":"<p>A port is a logical entity which represents an endpoint of communication and is associated with a given process or service in an operating system. In previous articles, we explained how to find out\u00a0<a href=\"https:\/\/www.tecmint.com\/find-open-ports-in-linux\/\" target=\"_blank\" rel=\"noopener\">list of all open ports in Linux<\/a>\u00a0and how to check if\u00a0<a href=\"https:\/\/www.tecmint.com\/check-remote-port-in-linux\/\" target=\"_blank\" rel=\"noopener\">remote ports are reachable using \u2018nc\u2019 command<\/a>.<\/p>\n<p>In this short guide, we will show different ways of finding the process\/service listening on a particular port in Linux.<\/p>\n<h3>1. Using netstat Command<\/h3>\n<p><a href=\"https:\/\/www.tecmint.com\/20-netstat-commands-for-linux-network-management\/\" target=\"_blank\" rel=\"noopener\">netstat (network statistics) command<\/a>\u00a0is used to display information concerning network connections, routing tables, interface stats and beyond. It is available on all Unix-like operating systems including Linux and also on Windows OS.<\/p>\n<p>In case you do not have it installed by default, use the following command to install it.<\/p>\n<pre>$ sudo yum install net-tools\t#RHEL\/CentOS \r\n$ sudo apt install net-tools\t#Debian\/Ubuntu\r\n$ sudo dnf install net-tools\t#Fedora 22+\r\n<\/pre>\n<p>Once installed, you can use it with\u00a0<a href=\"https:\/\/www.tecmint.com\/12-practical-examples-of-linux-grep-command\/\" target=\"_blank\" rel=\"noopener\">grep command<\/a>\u00a0to find the process or service listening on a particular port in Linux as follows (specify the port).<\/p>\n<pre>$ netstat -ltnp | grep -w ':80' \r\n<\/pre>\n<div id=\"attachment_26269\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Check-Port-Using-netstat-Command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26269\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Check-Port-Using-netstat-Command.png\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Check-Port-Using-netstat-Command.png 1026w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Check-Port-Using-netstat-Command-768x67.png 768w\" alt=\"Check Port Using netstat Command\" width=\"1026\" height=\"90\" aria-describedby=\"caption-attachment-26269\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26269\" class=\"wp-caption-text\">Check Port Using netstat Command<\/p>\n<\/div>\n<p>In the above command, the flags.<\/p>\n<ul>\n<li><code>l<\/code>\u00a0\u2013 tells netstat to only show listening sockets.<\/li>\n<li><code>t<\/code>\u00a0\u2013 tells it to display tcp connections.<\/li>\n<li><code>n<\/code>\u00a0\u2013 instructs it show numerical addresses.<\/li>\n<li><code>p<\/code>\u00a0\u2013 enables showing of the process ID and the process name.<\/li>\n<li><code>grep -w<\/code>\u00a0\u2013 shows matching of exact string (:80).<\/li>\n<\/ul>\n<h3>2. Using lsof Command<\/h3>\n<p><a href=\"https:\/\/www.tecmint.com\/10-lsof-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">lsof command<\/a>\u00a0(LiSt Open Files) is used to list all open files on a Linux system. To install it on your system, type the command below.<\/p>\n<pre>$ sudo yum install lsof\t        #RHEL\/CentOS \r\n$ sudo apt install lsof\t\t#Debian\/Ubuntu\r\n$ sudo dnf install lsof\t\t#Fedora 22+\r\n<\/pre>\n<p>To find the process\/service listening on a particular port, type (specify the port).<\/p>\n<pre>$ lsof -i :80\r\n<\/pre>\n<div id=\"attachment_26270\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Using-lsof-Command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26270\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Using-lsof-Command.png\" sizes=\"auto, (max-width: 853px) 100vw, 853px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Using-lsof-Command.png 853w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Using-lsof-Command-768x101.png 768w\" alt=\"Find Port Using lsof Command\" width=\"853\" height=\"112\" aria-describedby=\"caption-attachment-26270\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26270\" class=\"wp-caption-text\">Find Port Using lsof Command<\/p>\n<\/div>\n<h3>3. Using fuser Command<\/h3>\n<p><a href=\"https:\/\/www.tecmint.com\/learn-how-to-use-fuser-command-with-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">fuser command<\/a>\u00a0shows the PIDs of processes using the specified files or file systems in Linux.<\/p>\n<p>You can install it as follows:<\/p>\n<pre>$ sudo yum install psmisc\t#RHEL\/CentOS \r\n$ sudo apt install psmisc\t#Debian\/Ubuntu\r\n$ sudo dnf install psmisc\t#Fedora 22+\r\n<\/pre>\n<p>You can find the process\/service listening on a particular port by running the command below (specify the port).<\/p>\n<pre>$ fuser 80\/tcp\r\n<\/pre>\n<p>Then\u00a0<a href=\"https:\/\/www.tecmint.com\/find-process-name-pid-number-linux\/\" target=\"_blank\" rel=\"noopener\">find the process name using PID<\/a>\u00a0number with the\u00a0<strong>ps command<\/strong>\u00a0like so.<\/p>\n<pre>$ ps -p 2053 -o comm=\r\n$ ps -p 2381 -o comm=\r\n<\/pre>\n<div id=\"attachment_26271\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Process-ID.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26271\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/07\/Find-Port-Process-ID.png\" alt=\"Find Port and Process ID in Linux\" width=\"472\" height=\"178\" aria-describedby=\"caption-attachment-26271\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26271\" class=\"wp-caption-text\">Find Port and Process ID in Linux<\/p>\n<\/div>\n<p>You can also check out these useful guides about processes in Linux.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-process-management\/\" target=\"_blank\" rel=\"noopener\">All You Need To Know About Processes in Linux [Comprehensive Guide]<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/limit-cpu-usage-of-a-process-in-linux-with-cpulimit-tool\/\" target=\"_blank\" rel=\"noopener\">Limit CPU Usage of a Process in Linux with CPULimit Tool<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/find-and-kill-running-processes-pid-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Find and Kill Running Processes in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">Find Top Running Processes by Highest Memory and CPU Usage in Linux<\/a><\/li>\n<\/ol>\n<p>That\u2019s all! Do you know of any other ways of finding the process\/service listening on a particular port in Linux, let us know via the comment form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/find-out-which-process-listening-on-a-particular-port\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A port is a logical entity which represents an endpoint of communication and is associated with a given process or service in an operating system. In previous articles, we explained how to find out\u00a0list of all open ports in Linux\u00a0and how to check if\u00a0remote ports are reachable using \u2018nc\u2019 command. In this short guide, we &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/3-ways-to-find-out-which-process-listening-on-a-particular-port\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;3 Ways to Find Out Which Process Listening on a Particular Port&#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-13560","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\/13560","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=13560"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13560\/revisions"}],"predecessor-version":[{"id":13561,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13560\/revisions\/13561"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}