Skip to content

install netstat

To use netstat to check active connections and open ports, which can help in enabling the firewall, follow these steps:

  1. Install netstat (if not already installed):
  • On Debian-based systems like Ubuntu, you can install net-tools, which includes netstat:
sudo apt update
sudo apt install net-tools
  1. Check listening ports:
  • Use the following command to see all active connections and listening ports:

sudo netstat -tuln

  • -t shows TCP connections.
  • -u shows UDP connections.
  • -l shows only listening ports.
  • -n shows numeric addresses instead of resolving names.
  1. View specific details:
  • To view specific details about the processes listening on the ports:

sudo netstat -tulnp

  • -p shows the PID (Process ID) and the name of the program listening on each port.
Edited by peturbg