Ubuntu netstat Command: View Network Connection Status
In Ubuntu, `netstat` is a core network management tool used to view critical network data such as connections and routing tables. If not pre-installed, it can be installed by executing `sudo apt update && sudo apt install net-tools`. The basic syntax is `netstat [options]`, with commonly used parameters and their functions: - `-a` shows all connections (including TCP/UDP); - `-t`/`-u` filter TCP/UDP protocols respectively; - `-n` displays IP/port in numeric format (no DNS resolution); - `-l` only shows listening connections; - `-p` requires sudo privileges to display process IDs and names; - `-r` views the routing table. Typical application scenarios include: - Checking listening ports with `sudo netstat -tuln` (combination of `-tuln`: TCP/UDP listening, numeric format); - Troubleshooting port occupancy (e.g., port 80) with `sudo netstat -tulnp | grep 80`; - Viewing established TCP connections with `netstat -tan | grep ESTABLISHED`. Mastering core commands and parameter combinations (e.g., listening ports, port occupancy, routing tables) combined with tools like `grep` enables efficient network issue diagnosis.
Read More