# Which port is used

**URL:** <https://community.unix.com/t/which-port-is-used/379420>\
**Category:** AIX\
**Created:** [July 31, 2020, 9:15am UTC](https://community.unix.com/t/which-port-is-used/379420 "2020-07-31T09:15:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [July 31, 2020, 9:15am UTC](https://community.unix.com/t/which-port-is-used/379420/1 "2020-07-31T09:15:58Z")

</div>

Hi,  
On AIX, when running :

```
ps -ef | grep inherit
 oracle 8061180 1 0 Oct 13 - 15:06 /product/oracle/distrib/ora112039/db/bin/tnslsnr mydb-inheritj

```

How can I find which port is used by this process?

Thanks.

---

<div class="post-metadata">

**Author:** ![Mannu25251](https://community.unix.com/user_avatar/community.unix.com/mannu25251/32/14185_2.png) [@Mannu25251](https://community.unix.com/u/Mannu25251)\
**Post date:** [July 31, 2020, 1:16pm UTC](https://community.unix.com/t/which-port-is-used/379420/2 "2020-07-31T13:16:15Z")

</div>

try this -

```
sudo ss -ntlp | grep 8061180

```

4th column will let you know the port.

---

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [July 31, 2020, 2:48pm UTC](https://community.unix.com/t/which-port-is-used/379420/3 "2020-07-31T14:48:52Z")

</div>

> [@Mannu25251](#):
>
> `sudo ss -ntlp | grep 8061180`

Thank you. It asks me root password that I do not have.

Regards.

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [July 31, 2020, 3:21pm UTC](https://community.unix.com/t/which-port-is-used/379420/4 "2020-07-31T15:21:06Z")

</div>

Does `ss` exist on AIX?  
Googling this I get

> **[Finding which program is using a port in AIX](https://www.ibm.com/support/pages/finding-which-program-using-port-aix)**
>
> This solution shows how to determine which process is connected to a socket on an AIX box. This procedure is useful when it's not clear which process on a server is the client that's generating a specific operation in the audit.log

To list the details of a process ID the following is shorter: `ps -fp` _process\_id_

---

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [August 5, 2020, 3:14pm UTC](https://community.unix.com/t/which-port-is-used/379420/5 "2020-08-05T15:14:24Z")

</div>

Hi,  
Thanks.

```
ps -fp 8061180
     UID PID PPID C STIME TTY TIME CMD
  oracle 8061180 1 0 Oct 13 - 15:20 /u1/product/oracle/distrib/ora112039/db/bin/tnslsnr mydb -inherit

```

Does not show port in use.

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [August 5, 2020, 3:40pm UTC](https://community.unix.com/t/which-port-is-used/379420/6 "2020-08-05T15:40:24Z")

</div>

Did you run the

```nohighlight
netstat -Aan

```

?  
It shows all the ports that are in use.  
For each control block in column #1 you must map the PID with the `rmsock` command.  
When it matches the PID (that you already have) then it corresponds to the control block that corresponds to the `netstat -Aan` line that provides the port number.

---

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [August 5, 2020, 4:00pm UTC](https://community.unix.com/t/which-port-is-used/379420/7 "2020-08-05T16:00:47Z")

</div>

> [@MadeInGermany](#):
>
> you must map the PID with the `rmsock`

Thanks.  
Sorry cannot understand. Can you please give an exemple?  
regards.

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [August 5, 2020, 4:16pm UTC](https://community.unix.com/t/which-port-is-used/379420/8 "2020-08-05T16:16:57Z")

</div>

I cannot explain details, it is some years ago where I had access to an AIX system.  
Did you run the netstat command? Does the following yield something?

```nohighlight
netstat -Aan | grep LISTEN

```

---

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [August 5, 2020, 4:18pm UTC](https://community.unix.com/t/which-port-is-used/379420/9 "2020-08-05T16:18:59Z")

</div>

> [@MadeInGermany](#):
>
> `netstat -Aan | grep LISTEN`

Yes:

```plaintext
$ netstat -Aan | grep LISTEN
f1000e00143a2bb8 tcp6 0 0 *.22 *.* LISTEN
f1000e00149f9bb8 tcp4 0 0 *.22 *.* LISTEN
f1000e00040293b8 tcp 0 0 *.24537 *.* LISTEN
f1000e0003fba3b8 tcp 0 0 *.111 *.* LISTEN

```

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [August 5, 2020, 4:55pm UTC](https://community.unix.com/t/which-port-is-used/379420/10 "2020-08-05T16:55:11Z")

</div>

please start using [markdown tags](https://www.markdownguide.org/cheat-sheet/#extended-syntax) when posting code/data samples - I've edited your last post (for now).  
Does this (Googled) [link](https://www.ibm.com/support/pages/finding-which-program-using-port-aix) help?  
(I see I could use Google as well as @MadeInGermany - that's encouraging)

---

<div class="post-metadata">

**Author:** ![big123456](https://community.unix.com/letter_avatar/big123456/32/6_22734026db12803ebb3e059622ac3534.png) [@big123456](https://community.unix.com/u/big123456)\
**Post date:** [August 5, 2020, 5:07pm UTC](https://community.unix.com/t/which-port-is-used/379420/11 "2020-08-05T17:07:40Z")

</div>

Thanks. I don't understand what you mean by " please start using ...".  
I will take a look at that link.  
Regards.
