Digital Marketing

How to check which process/program is using your port on Linux

To check which process/program is using your port on linux, for example, to see which process is using port 80

$ sudo -i lsof -i TCP:80
Which process is using port 443

$ sudo lsof -i :443 
 
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 2938 root 4u IPv6 58369 0t0 TCP *:http (LISTEN)
httpd 27835 apache 4u IPv6 58369 0t0 TCP *:http (LISTEN)
httpd 27836 apache 4u IPv6 58369 0t0 TCP *:http (LISTEN)


Check port 4848
$ sudo -i lsof -i TCP:4848
Another way is using ss (which deprecates netstat on Redhat 7):

$ sudo -i ss -nap | grep 4848
tcp    LISTEN     0      128                  :::4848                 :::*      users:(("java",16491,385))
$ ss -lpa -A inet | grep https

$ ss -lpa -A inet | grep java

ss - another utility to investigate sockets
ss  is used to dump socket statistics. It allows showing information similar to netstat.  It can display more TCP and state
       informations than other tools.
-a, --all
              Display both listening and non-listening (for TCP this means established connections) sockets.
 -n, --numeric
              Do not try to resolve service names.
 -l, --listening
              Display only listening sockets (these are omitted by default).
 -p, --processes
              Show process using socket.
-A QUERY, --query=QUERY, --socket=QUERY
              List  of  socket tables to dump, separated by commas. The following identifiers are understood: all, inet, tcp, udp, raw, unix, packet, netlink, unix_dgram, unix_stream, unix_seqpacket, packet_raw, packet_dgram.

Comments

Popular posts from this blog

Make online money from the Internet