Linux command: netstat
When one computer talks to another, Linux keeps track of the local ends of those conversations. A socket is one such communication endpoint, and a listening socket waits for someone to connect. netstat displays sockets and other network information, so it can help answer a simple question: is a program waiting on the port I expect? The port is a numbered endpoint on the computer, like a labeled door for a network service. A listing gives clues about the local system; it cannot show by itself whether a remote user can reach the service.
netstat is part of the older net-tools package, which may not be installed. Many modern Linux systems use iproute2 tools for current socket and network diagnostics, but netstat remains useful on systems where it is available.
netstat -tuln selects TCP and UDP sockets, listening sockets, and numeric addresses and ports. Numeric output avoids name lookups, making it easier to compare an endpoint with a firewall rule. Add -a to include non-listening sockets as well. The -p option requests the process and PID associated with a socket, when the implementation supports it and the caller has permission. Missing process details do not necessarily mean no process owns the socket.
The local and foreign endpoint columns show which addresses and ports are involved. TCP rows have connection states: a listening socket waits for connections, while ESTABLISHED indicates a completed TCP connection. UDP has no TCP-style connection state, so its output should not be interpreted in the same way. A listener bound to a wildcard address may accept traffic on several local interfaces, subject to routing and firewall policy.
To check whether a service is listening on port :8080, look for that endpoint in netstat -tuln. If the process owner is useful, try sudo netstat -tulpn when netstat is installed and the account is permitted to use sudo. A socket listing describes the local network namespace; it does not prove that a remote client can connect. Check the bind address, firewall, route, container or network namespace, and application health separately.
For socket inspection on current Linux systems, ss is usually the direct tool to try. ss -lnt lists listening TCP sockets with numeric endpoints, and ss -lun does the same for UDP. ss -tpn can show TCP process information when permissions allow it. Filters can narrow output to an address, state, or port. For routes, the ip suite provides ip route; for interface counters, ip -s link is generally more useful than netstat -r or netstat -i.
Service names can obscure port numbers: /etc/services maps common numbers to labels. Compare numeric output when a rule or configuration names a port. A listener confirms that a socket exists in the viewed context, not that the application responds correctly or is reachable from every network.




