Sobes.tech
Middle+

How to view open sockets in the system?

sobes.tech AI

Answer from AI

To view open sockets in the system, you can use several commands depending on the OS and tasks:

  • netstat — a classic utility for displaying network connections.
netstat -tunlp
  • -t — TCP

  • -u — UDP

  • -n — show addresses and ports in numeric form

  • -l — listening sockets

  • -p — show PID and process name

  • ss — a modern alternative to netstat, faster and more informative.

ss -tunlp
  • lsof — shows open files, including sockets.
lsof -i
  • To view sockets of a specific process, you can use:
ls -l /proc/<pid>/fd | grep socket

These tools will help identify which sockets are open, on which ports, and by which processes.