{"id":1523,"date":"2019-04-22T07:56:52","date_gmt":"2019-04-22T02:26:52","guid":{"rendered":"http:\/\/jaipurhosting.com\/blog\/?p=1523"},"modified":"2019-04-30T10:41:59","modified_gmt":"2019-04-30T05:11:59","slug":"how-to-find-out-which-process-listening-on-a-particular-port","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/how-to-find-out-which-process-listening-on-a-particular-port\/","title":{"rendered":"How to find out which process listening on a particular port"},"content":{"rendered":"\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>Description<\/strong><\/p>\n\n\n\n<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.<\/p>\n\n\n\n<p>In this blog we can see the different ways of finding the process\/service listening on a particular port in Linux. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>1.Using netstat Command<\/strong><\/p>\n\n\n\n<p>netstat (network statistics) command&nbsp;is used to display information concerning network connections, routing tables, interface stats and beyond.<\/p>\n\n\n\n<p> It is available on all Unix-like operating systems including Linux and also on Windows OS. <\/p>\n\n\n\n<p>In case you do not have it installed by default, use the following command to install it. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo yum install net-tools\t#RHEL\/CentOS \n$ sudo apt install net-tools\t#Debian\/Ubuntu\n$ sudo dnf install net-tools\t#Fedora 22+<\/code><\/pre>\n\n\n\n<p>Once installed, you can use it with&nbsp;grep command&nbsp;to find the process or service listening on a particular port in Linux as follows (specify the port).<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ netstat -ltnp | grep -w ':80'<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jaipurhosting.com\/blog\/wp-content\/uploads\/2019\/04\/1.png\" alt=\"\" class=\"wp-image-1524\" width=\"578\" height=\"58\"\/><\/figure>\n\n\n\n<p>In the above command, the flags. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> <code>l<\/code>&nbsp;\u2013 tells netstat to only show listening sockets. <\/li><li> <code>t<\/code>&nbsp;\u2013 tells it to display tcp connections. <\/li><li> <code>n<\/code>&nbsp;\u2013 instructs it show numerical addresses. <\/li><li> <code>p<\/code>&nbsp;\u2013 enables showing of the process ID and the process name. <\/li><li> <code>grep -w<\/code>&nbsp;\u2013 shows matching of exact string (:80). <\/li><\/ul>\n\n\n\n<p class=\"has-medium-font-size\"><strong>2.Using lsof Command<\/strong><\/p>\n\n\n\n<p>lsof command&nbsp;(LiSt Open Files) is used to list all open files on a Linux system. <\/p>\n\n\n\n<p>To install it on your system, type the command below. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo yum install lsof\t        #RHEL\/CentOS \n$ sudo apt install lsof\t\t#Debian\/Ubuntu\n$ sudo dnf install lsof\t\t#Fedora 22+<\/code><\/pre>\n\n\n\n<p>To find the process\/service listening on a particular port, type (specify the port). <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ lsof -i :80<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>3.Using fuser Command<\/strong><\/p>\n\n\n\n<p>fuser command&nbsp;shows the PIDs of processes using the specified files or file systems in Linux. <\/p>\n\n\n\n<p>You can install it as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo yum install psmisc\t#RHEL\/CentOS \n$ sudo apt install psmisc\t#Debian\/Ubuntu\n$ sudo dnf install psmisc\t#Fedora 22+<\/code><\/pre>\n\n\n\n<p>You can find the process\/service listening on a particular port by running the command below (specify the port). <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fuser 80\/tcp<\/code><\/pre>\n\n\n\n<p>Then find the process name using PID&nbsp;number with the&nbsp;<strong>ps command<\/strong>&nbsp;like so. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ps -p 2053 -o comm=\n$ ps -p 2381 -o comm=<\/code><\/pre>\n\n\n\n<p>That\u2019s all! Do you know of any other ways of finding the process\/service listening on a particular port in Linux<\/p>\n\n\n\n<p><br>We hope you\u2019ve found this useful! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description 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 this blog we can see the different ways of finding the process\/service listening on a particular port in Linux. 1.Using netstat Command netstat (network statistics) command&nbsp;is used to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1527,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=1523"}],"version-history":[{"count":2,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1523\/revisions"}],"predecessor-version":[{"id":1533,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1523\/revisions\/1533"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1527"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=1523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=1523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=1523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}