{"id":731,"date":"2021-04-14T16:28:38","date_gmt":"2021-04-14T15:28:38","guid":{"rendered":"http:\/\/hslomka.de\/techno\/?p=731"},"modified":"2026-03-16T15:33:38","modified_gmt":"2026-03-16T15:33:38","slug":"prozess-zu-einem-offenen-port-ermitteln","status":"publish","type":"post","link":"https:\/\/techno.slomka.biz\/?p=731","title":{"rendered":"Identifying the Process on an Open Port"},"content":{"rendered":"\n<p>There are several ways to find the process on an open port. As an example, let&#8217;s find out which process is running on port 5000. The first attempt could be to use `grep` on the port with <code>ps -ef<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>dockeradm@ubuntusrv001:~$ ps -ef|grep 5000\nUID PID PPID C STIME TTY TIME CMD\nroot 80078 79851 0 14:42 ? 00:00:00 \/usr\/bin\/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5000 -container-ip 172.17.0.2 -container-port 5000\nroot 80087 79851 0 14:42 ? 00:00:00 \/usr\/bin\/docker-proxy -proto tcp -host-ip :: -host-port 5000 -container-ip 172.17.0.2 -container-port 5000<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">dockeradm@ubuntusrv001:~$<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">ps<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-ef<\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #FFCB6B\">grep<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">UID<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">PID<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">PPID<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">C<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">STIME<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">TTY<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">TIME<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">CMD<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">root<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80078<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">79851<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">14<\/span><span style=\"color: #C3E88D\">:42<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">?<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">00<\/span><span style=\"color: #C3E88D\">:00:00<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">\/usr\/bin\/docker-proxy<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-proto<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">tcp<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-host-ip<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0.0<\/span><span style=\"color: #C3E88D\">.0.0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-host-port<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-container-ip<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">172.17<\/span><span style=\"color: #C3E88D\">.0.2<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-container-port<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">root<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80087<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">79851<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">14<\/span><span style=\"color: #C3E88D\">:42<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">?<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">00<\/span><span style=\"color: #C3E88D\">:00:00<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">\/usr\/bin\/docker-proxy<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-proto<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">tcp<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-host-ip<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">::<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-host-port<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-container-ip<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">172.17<\/span><span style=\"color: #C3E88D\">.0.2<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-container-port<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This approach is only successful if a process receives the port as an argument. This is only the case in a few instances.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">LSOF<\/h2>\n\n\n\n<p>The <code>lsof<\/code> command with the <code>-i<\/code> option followed by <code>:&lt;PORT&gt;<\/code> displays the processes that are keeping this port open.<\/p>\n\n\n\n<p>\ud83d\udca1If you are not the technical user under which the process is running, you will not see any output.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>dockeradm@ubuntusrv001:~$ lsof -i :5000<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">dockeradm@ubuntusrv001:~$<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">lsof<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-i<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">:5000<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Using sudo or as the user who owns the process, the process name and process ID are displayed:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>dockeradm@ubuntusrv001:~$ sudo lsof -i :5000\nCOMMAND PID USER FD TYPE DEVICE SIZE\/OFF NODE NAME\ndocker-pr 80078 root 4u IPv4 665614 0t0 TCP *:5000 (LISTEN)\ndocker-pr 80087 root 4u IPv6 660124 0t0 TCP *:5000 (LISTEN)<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">dockeradm@ubuntusrv001:~$<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">sudo<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">lsof<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-i<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">:5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">COMMAND<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">PID<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">USER<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">FD<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">TYPE<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">DEVICE<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">SIZE\/OFF<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">NODE<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">NAME<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">docker-pr<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80078<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">root<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">4<\/span><span style=\"color: #C3E88D\">u<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">IPv4<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">665614<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #C3E88D\">t0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">TCP<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #C3E88D\">:5000<\/span><span style=\"color: #EEFFFF\"> (LISTEN)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">docker-pr<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80087<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">root<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">4<\/span><span style=\"color: #C3E88D\">u<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">IPv6<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">660124<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #C3E88D\">t0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">TCP<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #C3E88D\">:5000<\/span><span style=\"color: #EEFFFF\"> (LISTEN)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">NETSTAT<\/h2>\n\n\n\n<p><code>netstat<\/code> also displays the process and port (when logged in as the technical user under which the process is running or as root). If you are not the technical user, the process name will not be displayed.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>dockeradm@ubuntusrv001:~$ netstat -tulnp|grep 5000\n(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)\ntcp     0    0  0.0.0.0:5000   0.0.0.0:*   LISTEN   -\ntcp6    0    0  :::5000        :::*        LISTEN   - <\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">dockeradm@ubuntusrv001:~$<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">netstat<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-tulnp<\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #FFCB6B\">grep<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #FFCB6B\">Not<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">all<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">processes<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">could<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">be<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">identified,<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">non-owned<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">process<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">info<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">will<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">not<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">be<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">shown,<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">you<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">would<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">have<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">to<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">be<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">root<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">to<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">see<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">it<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">all.<\/span><span style=\"color: #89DDFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">tcp<\/span><span style=\"color: #EEFFFF\">     <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">    <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">  <\/span><span style=\"color: #F78C6C\">0.0<\/span><span style=\"color: #C3E88D\">.0.0:5000<\/span><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">0.0<\/span><span style=\"color: #C3E88D\">.0.0:<\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #C3E88D\">LISTEN<\/span><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #C3E88D\">-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">tcp6<\/span><span style=\"color: #EEFFFF\">    <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">    <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">  <\/span><span style=\"color: #C3E88D\">:::5000<\/span><span style=\"color: #EEFFFF\">        <\/span><span style=\"color: #C3E88D\">:::<\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #EEFFFF\">        <\/span><span style=\"color: #C3E88D\">LISTEN<\/span><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #C3E88D\">-<\/span><span style=\"color: #EEFFFF\"> <\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>As the user who owns the process, or as root, you can also see the associated process.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>dockeradm@ubuntusrv001:~$ sudo netstat -tulnp|grep 5000\ntcp   0  0 0.0.0.0:5000 0.0.0.0:* LISTEN 80078\/docker-proxy\ntcp6  0  0 :::5000        :::*    LISTEN 80087\/docker-proxy<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">dockeradm@ubuntusrv001:~$<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">sudo<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">netstat<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-tulnp<\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #FFCB6B\">grep<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">tcp<\/span><span style=\"color: #EEFFFF\">   <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">  <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0.0<\/span><span style=\"color: #C3E88D\">.0.0:5000<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">0.0<\/span><span style=\"color: #C3E88D\">.0.0:<\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">LISTEN<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80078<\/span><span style=\"color: #C3E88D\">\/docker-proxy<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">tcp6<\/span><span style=\"color: #EEFFFF\">  <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\">  <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">:::5000<\/span><span style=\"color: #EEFFFF\">        <\/span><span style=\"color: #C3E88D\">:::<\/span><span style=\"color: #EEFFFF\">*<\/span><span style=\"color: #EEFFFF\">    <\/span><span style=\"color: #C3E88D\">LISTEN<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #F78C6C\">80087<\/span><span style=\"color: #C3E88D\">\/docker-proxy<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p><code>netstat<\/code> always produces output. At least you can see that a process is using the port and its status (CONNECTED\/LISTEN\/&#8230;). Under certain circumstances, ps and lsof will show no results if permissions are insufficient, even though a process is using the port.<br><br><br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several ways to find the process on an open port. As an example, let&#8217;s find out which process is running on port 5000. The first attempt could be to use `grep` on the port with ps -ef. This approach is only successful if a process receives the port as an argument. This is only the case in a few instances. LSOF The lsof command with the -i option followed by :&lt;PORT&gt; displays the processes that are keeping this port open. \ud83d\udca1If you are not the technical user under which the process is running, you will not see any output. Using sudo or as the user who owns the process, the process name and process ID are displayed: NETSTAT netstat also displays the process and port (when logged in as the technical user under which the process is running or as root). If you are not the technical user, the process name will not be displayed. As the user who owns the process, or as root, you can also see the associated process. Conclusion netstat always produces output. At least you can see that a process is using the port and its status (CONNECTED\/LISTEN\/&#8230;). Under certain circumstances, ps and lsof will show no results if permissions are insufficient, even though a process is using the port.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,9,14,25],"tags":[46,72,73],"class_list":["post-731","post","type-post","status-publish","format-standard","hentry","category-debian","category-linux","category-redhat","category-ubuntu","tag-bash","tag-ksh","tag-linux"],"_links":{"self":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=731"}],"version-history":[{"count":18,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions"}],"predecessor-version":[{"id":1120,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/731\/revisions\/1120"}],"wp:attachment":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}