List listening TCP and UDP ports with owning processes
Build a paste-ready command, then review its compatibility and effects before running it.
read-onlyrequires privileges Compatibility
Linux net-toolsnetstat is legacy on Linux; the ss-based linux-sockets command is the preferred modern alternative.
Operational knowledgereview due 2027-01-19
Requirementsnetstatnetstat must be installed and available on PATH.Elevated accessReview the exact scope before using an elevated account.
Version supportnetstat Current supported releasesVerified for linux using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signalsProto Recv-Q Send-Q Local Address Foreign Address State PID/Program nameRepresentative successful output; values vary with the selected target and system state.
Known errorsnetstat: command not foundnetstat is missing or is not available on PATH.Permission deniedThe current identity does not have the required access.
Verifysudo netstat -tulpnThe output matches the expected target and exits without an error.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01sudoPrivilege elevationRuns the following command with elevated privileges after authorization.
02netstatCommandRuns the netstat stage of this one-liner.
03-tulpnOptionShows TCP and UDP listeners numerically, including owning process details.
Example input
sudo netstat -tulpn
Example output
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 912/sshd
tcp6 0 0 :::443 :::* LISTEN 1842/nginx
udp 0 0 0.0.0.0:51820 0.0.0.0:* -
Illustrative output — exact values vary by system and data.
Official sources
Related commands