---
name: list_listening_ports
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "list_listening_ports([mode: string]) -> void"
description: "Lista puertos activos del sistema usando ss (preferido) o netstat como fallback. Modos: all (LISTEN), tcp, udp, established (conexiones activas), stats (resumen + interfaces). Imprime salida tabulada a stdout."
tags: [bash, ports, network, listening, monitoring]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: mode
    desc: "qué listar: all|tcp|udp|established|stats (default: all)"
output: "tabla de puertos/conexiones a stdout; exit code 1 si no hay ss ni netstat, o si el modo es desconocido"
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/list_listening_ports.sh"
source_repo: "https://gitea-dgg044oo04woo4ggcsws4gk0.organic-machine.com/egutierrez/DevLauncher.git"
source_license: "MIT"
source_file: "scripts/linux/gestion_linux/puertos_activos.sh"
---

## Ejemplo

```bash
source bash/functions/infra/list_listening_ports.sh

# Todos los puertos en escucha
list_listening_ports

# Solo TCP
list_listening_ports tcp

# Conexiones establecidas
list_listening_ports established

# Estadísticas e interfaces
list_listening_ports stats
```

## Notas

Prefiere `ss` (iproute2) sobre `netstat` (net-tools). El modo `established` limita a 30 filas para no saturar el terminal. No incluye monitor en tiempo real (solo snapshot).
