sajad torkamani
sudo lsof -Pn -i
  • lsof: list open files.
  • -P: prevent conversion of port numbers to port names (e.g., display 80 instead of http).
  • -n: prevent conversion of network numbers to network names (e.g., display 201.87.138.40 instead of production).
  • -i: only show internet addresses (i.e., in the form [protocol][@hostname|hostaddr][:service|port]).

Example output:

systemd-r   576 systemd-resolve   12u  IPv4  19554      0t0  UDP 127.0.0.53:domain
systemd-r   576 systemd-resolve   13u  IPv4  19555      0t0  TCP 127.0.0.53:domain (LISTEN)
sshd        810            root    3u  IPv4  23158      0t0  TCP *:ssh (LISTEN)
nginx      3741            root    6u  IPv4  39232      0t0  TCP *:http (LISTEN)
mysqld    51376           mysql   22u  IPv4 245218      0t0  TCP 127.0.0.1:33060 (LISTEN)
mysqld    51376           mysql   36u  IPv6 245221      0t0  TCP *:3306 (LISTEN)
nginx     60975        www-data    4u  IPv4 553894      0t0  TCP 201.87.138.40:http->5.255.253.156:57913 (ESTABLISHED)
nginx     60975        www-data    5u  IPv4 553874      0t0  TCP 201.87.138.40:http->17.250.222.54:45181 (ESTABLISHED)
nginx     60975        www-data    6u  IPv4  39232      0t0  TCP *:http (LISTEN)
sshd      84026            root    4u  IPv4 551973      0t0  TCP 201.87.138.40:ssh->85.9.223.174:50151 (ESTABLISHED)
sshd      84113           sajad    4u  IPv4 551973      0t0  TCP 201.87.138.40:ssh->85.9.223.174:50151 (ESTABLISHED)
Tagged: Networking