lunes, 3 de junio de 2019

Identify a process who is listening in a port


Sometimes you need to identify a process than is associated to a TCP port.
You can use ss instead netstat command to identify them.

For instance, if you want to identify what is the process who is listen on TCP port 80, use the following command:

# ss -ltnp | grep -w ':80'
LISTEN   0         128                 0.0.0.0:80               0.0.0.0:*        users:(("nginx",pid=24503,fd=13),("nginx",pid=24502,fd=13),("nginx",pid=24499,fd=13))


Where:
  • l – tells netstat to only show listening sockets.
  • t – tells it to display tcp connections.
  • n – instructs it show numerical addresses.
  • p – enables showing of the process ID and the process name.

Then, with the process number (i.e. 24499) you can get the process detail with:
# ls -l /proc/24499/exe
lrwxrwxrwx. 1 root root 0 Jun  3 08:37 /proc/24499/exe -> /opt/opscode/embedded/sbin/nginx

No hay comentarios:

Publicar un comentario

How to save a remote server SSL certificate locally as a file?

I found this answer following answer on StackExcahnge and it works perfect. Enjoy! "A quick method to get the certificate pulled and...