{"id":515,"date":"2008-06-10T14:59:22","date_gmt":"2008-06-10T18:59:22","guid":{"rendered":"http:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/"},"modified":"2009-12-01T06:32:12","modified_gmt":"2009-12-01T10:32:12","slug":"how-to-find-pid-listening-particular-port-on-linuxsolaris-10","status":"publish","type":"post","link":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/","title":{"rendered":"How to find PID listening particular Port on Linux\/Solaris 10"},"content":{"rendered":"<p>If you are trying to run any apps service (adapcctl.sh, opmnctl, lsnrctl) and get message like\u00a0 &#8220;<strong>unable to bind port &lt;port_number&gt;<\/strong>&#8221; (Most probably this port is in use by other process), <strong>fix is to<\/strong> either start your service on different port <strong>or terminate process<\/strong> listening on that particular port using <strong>kill -9 &lt;pid&gt;<\/strong><\/p>\n<p>In order to kill that specific pid, you need to find pid which is listening on that specific port. There are lot of ways to find pid which is listening\/using specific port and most commonly used is <strong>LSOF<\/strong><\/p>\n<p><strong><u>What is lsof ?<\/u><br \/>\n<\/strong>lsof which stands for <strong>L<\/strong>i<strong>S<\/strong>t <strong>O<\/strong>pen <strong>F<\/strong>iles is Unix utility to list all open files and processes that opened them on Unix.<\/p>\n<p>&#8211;<br \/>\n<strong><u>How to use LSOF ?<\/u><\/strong><\/p>\n<p><strong>lsof | grep &lt;port_number&gt;<\/strong>\u00a0 ( on <strong>Solaris,<\/strong>lsof is usually installed under <strong>\/usr\/local\/bin<\/strong> where as on <strong>Linux<\/strong> its usually under <strong>\/usr\/sbin<\/strong> )<\/p>\n<p><font color=\"#ff0000\">Beware if you are on Solaris 10 and using <strong>ZONES<\/strong><\/font>(more on zones in solaris 10 coming soon) :<br \/>\n1. lsof <strong>doesn&#8217;t<\/strong> work from <strong>non-global zone <\/strong>in solaris 10<br \/>\n2. Use <strong>-z option <\/strong>with lsof to list open files &amp; processes with in <strong>non-global zone<\/strong> like &#8220;<strong>lsof -z<\/strong>&#8221;<br \/>\n3. Solaris 10 with zones list doesn&#8217;t display port , hence I used script mentioned at end of this post.<\/p>\n<p>Once you know PID using specific port, you can either stop it or terminate using<br \/>\n<strong>kill -9 &lt;pid&gt;<\/strong><br \/>\n<strong><u><\/u><\/strong><\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u>Key points for lsof on solaris<br \/>\n<\/u><\/strong><br \/>\n1) Installation procedure of lsof on solaris is same for Solaris Sparc or X86\u00a0&amp; on\u00a0version 9 or 10 only difference is file name<\/p>\n<p>2) lsof doesn&#8217;t work from zone\u00a0 (More on zones in solaris 10 coming soon), You have to\u00a0install lsof\u00a0on <strong>global zone<\/strong>.\u00a0 If you run lsof and get error message like &#8220;<strong>lsof: can&#8217;t stat(\/devices): No such file or directory<\/strong>&#8221; probably you are running lsof with in solaris 10 Zone.<\/p>\n<p>3) lsof on solaris is installed under <strong>\/usr\/local\/bin<\/strong> (default location)<\/p>\n<p>4) On Solaris 10, using &#8220;<strong>lsof -i<\/strong>&#8221; to show mapping of processes to TCP ports incorrectly shows all processes that have socket open as using port 65535. (<font color=\"#ff0000\">Use script mentioned at end of file in such cases<\/font>)<\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u>How to install lsof on Solaris 10<\/u><br \/>\n<\/strong>lsof is part of Red Hat Linux (By default its installed under <strong>\/usr\/sbin<\/strong>), for Solaris\u00a0lsof is available <a target=\"_blank\" href=\"http:\/\/www.sunfreeware.com\">as freeware here<\/a>\u00a0for <strong>Solaris Sparc 10<\/strong>\u00a0download it \u00a0<a target=\"_blank\" href=\"http:\/\/www.sunfreeware.com\/programlistsparc10.html\">from here<\/a><\/p>\n<p>1. Download lsof executable for Solaris 10 on sparc <a target=\"_blank\" href=\"ftp:\/\/ftp.sunfreeware.com\/pub\/freeware\/sparc\/10\/lsof_0606-4.77-sol10-sparc-local.gz\">from here<\/a>\u00a0 or <a target=\"_blank\" href=\"http:\/\/www.sunfreeware.com\/\">from here <\/a>if you are on different processor or version.<\/p>\n<p>2. Upload zip file like <strong>lsof_0606-4.77-sol10-sparc-local.gz<\/strong>\u00a0 to server<\/p>\n<p>3. Unzip as <strong>gunzip lsof_0606-4.77-sol10-sparc-local.gz<\/strong>\u00a0 (This will create file like lsof_0606-4.77-sol10-sparc-local)<\/p>\n<p>4. pkgadd -d lsof_0606-4.77-sol10-sparc-local\u00a0 (Run this command from root user from global zone)<\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u>If you are on Solaris 10 use below script to list port <\/u><\/strong><\/p>\n<p>create file like <strong>get_pid_from_port.sh\u00a0\u00a0 (Or download script <a target=\"_blank\" href=\"https:\/\/onlineappsdba.com\/scripts\/os\/get_pid_from_port_solaris.txt\">from here<\/a>)<br \/>\n<\/strong><\/p>\n<p><font color=\"#ff0000\">#!\/bin\/bash<br \/>\n# $1 is the port we are looking for<\/font><\/p>\n<p><font color=\"#ff0000\">if [ $# -lt 1 ]<br \/>\nthen<br \/>\necho &#8220;Please provide a port number parameter for this script&#8221;<br \/>\necho &#8220;e.g. $0 1521&#8221;<br \/>\nexit<br \/>\nfi<\/font><\/p>\n<p><font color=\"#ff0000\">echo &#8220;Greping for your port, please be patient (CTRL+C breaks) &#8230; &#8220;<\/font><\/p>\n<p><font color=\"#ff0000\">for i in `ls \/proc`<br \/>\ndo<br \/>\npfiles $i | grep AF_INET | grep\u00a0$ 1<br \/>\nif [ $? -eq 0 ]<br \/>\nthen<br \/>\necho Is owned by pid $i<br \/>\necho &#8212;&#8212;<br \/>\nfi<br \/>\ndone<\/font><\/p>\n<p><font color=\"#000000\">and execute this script like<br \/>\n<strong>sh get_pid_from_port.sh &lt;port_num&gt;<\/strong><br \/>\n<strong>sh get_pid_from_port.sh 8000 <\/strong>(To find pid using port 8000)<\/font><\/p>\n<p>(I got this script from net last year and now I can&#8217;t find Author of this script. In case I find authour or link I&#8217;ll remove from here and link to original site)<strong><u><\/u><\/strong><strong><u><\/u><\/strong><\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u><\/u><\/strong><\/p>\n<p><strong><u>Related<\/u><\/strong><strong><u><br \/>\n<\/u><\/strong><strong><u><br \/>\n<a target=\"_blank\" href=\"http:\/\/www.mirrorservice.org\/sites\/vic.cc.purdue.edu\/pub\/tools\/unix\/lsof\/FAQ\">LSOF FAQ<br \/>\n<\/a><a target=\"_blank\" href=\"http:\/\/www.opensource.apple.com\/darwinsource\/10.3\/lsof-12\/lsof\/00QUICKSTART\">Quick Start for LSOF<\/a>\u00a0<\/u><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are trying to run any apps service (adapcctl.sh, opmnctl, lsnrctl) and get message like\u00a0 &#8220;unable to bind port [&hellip;]<\/p>\n","protected":false},"author":115,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[134],"tags":[],"class_list":["post-515","post","type-post","status-publish","format-standard","hentry","category-unix"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to find PID listening particular Port on Linux\/Solaris 10 -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to find PID listening particular Port on Linux\/Solaris 10 -\" \/>\n<meta property=\"og:description\" content=\"If you are trying to run any apps service (adapcctl.sh, opmnctl, lsnrctl) and get message like\u00a0 &#8220;unable to bind port [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/\" \/>\n<meta property=\"article:published_time\" content=\"2008-06-10T18:59:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-12-01T10:32:12+00:00\" \/>\n<meta name=\"author\" content=\"Masroof Ahmad\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Masroof Ahmad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/\",\"url\":\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/\",\"name\":\"How to find PID listening particular Port on Linux\/Solaris 10 -\",\"isPartOf\":{\"@id\":\"https:\/\/onlineappsdba.com\/#website\"},\"datePublished\":\"2008-06-10T18:59:22+00:00\",\"dateModified\":\"2009-12-01T10:32:12+00:00\",\"author\":{\"@id\":\"https:\/\/onlineappsdba.com\/#\/schema\/person\/909a876ed58d400faf82caf81d61bfdb\"},\"breadcrumb\":{\"@id\":\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/onlineappsdba.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to find PID listening particular Port on Linux\/Solaris 10\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/onlineappsdba.com\/#website\",\"url\":\"https:\/\/onlineappsdba.com\/\",\"name\":\"\",\"description\":\"Oracle Implementation &amp; Training Experts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/onlineappsdba.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/onlineappsdba.com\/#\/schema\/person\/909a876ed58d400faf82caf81d61bfdb\",\"name\":\"Masroof Ahmad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/onlineappsdba.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/10f9db7bdbbd7f9ccfbe9b2d208e5978fc28315e9c704383e639a926ea0fce5f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/10f9db7bdbbd7f9ccfbe9b2d208e5978fc28315e9c704383e639a926ea0fce5f?s=96&d=mm&r=g\",\"caption\":\"Masroof Ahmad\"},\"url\":\"https:\/\/onlineappsdba.com\/index.php\/author\/masroof\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to find PID listening particular Port on Linux\/Solaris 10 -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/","og_locale":"en_US","og_type":"article","og_title":"How to find PID listening particular Port on Linux\/Solaris 10 -","og_description":"If you are trying to run any apps service (adapcctl.sh, opmnctl, lsnrctl) and get message like\u00a0 &#8220;unable to bind port [&hellip;]","og_url":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/","article_published_time":"2008-06-10T18:59:22+00:00","article_modified_time":"2009-12-01T10:32:12+00:00","author":"Masroof Ahmad","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Masroof Ahmad","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/","url":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/","name":"How to find PID listening particular Port on Linux\/Solaris 10 -","isPartOf":{"@id":"https:\/\/onlineappsdba.com\/#website"},"datePublished":"2008-06-10T18:59:22+00:00","dateModified":"2009-12-01T10:32:12+00:00","author":{"@id":"https:\/\/onlineappsdba.com\/#\/schema\/person\/909a876ed58d400faf82caf81d61bfdb"},"breadcrumb":{"@id":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/onlineappsdba.com\/index.php\/2008\/06\/10\/how-to-find-pid-listening-particular-port-on-linuxsolaris-10\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/onlineappsdba.com\/"},{"@type":"ListItem","position":2,"name":"How to find PID listening particular Port on Linux\/Solaris 10"}]},{"@type":"WebSite","@id":"https:\/\/onlineappsdba.com\/#website","url":"https:\/\/onlineappsdba.com\/","name":"","description":"Oracle Implementation &amp; Training Experts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/onlineappsdba.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/onlineappsdba.com\/#\/schema\/person\/909a876ed58d400faf82caf81d61bfdb","name":"Masroof Ahmad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/onlineappsdba.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/10f9db7bdbbd7f9ccfbe9b2d208e5978fc28315e9c704383e639a926ea0fce5f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/10f9db7bdbbd7f9ccfbe9b2d208e5978fc28315e9c704383e639a926ea0fce5f?s=96&d=mm&r=g","caption":"Masroof Ahmad"},"url":"https:\/\/onlineappsdba.com\/index.php\/author\/masroof\/"}]}},"_links":{"self":[{"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/posts\/515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/users\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/comments?post=515"}],"version-history":[{"count":0,"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/posts\/515\/revisions"}],"wp:attachment":[{"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/media?parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/categories?post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/onlineappsdba.com\/index.php\/wp-json\/wp\/v2\/tags?post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}