Summarize listening TCP sockets by address and owning process
Build a paste-ready command, then review its compatibility and effects before running it.
ss -lntpH | awk '{printf "%-24s %-10s %s\n", $4, $2, $NF}' | sort -k1,1read-onlyno known side effects Compatibility
LinuxVerified for Linux using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsssss must be installed and available on PATH.
Version supportss Current supported releasesVerified for linux using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals0.0.0.0:22 128 users:(("sshd",pid=812,fd=3))Representative successful output; values vary with the selected target and system state.
Known errorsss: command not foundss is missing or is not available on PATH.
Verifyss -lntpH | awk '{printf "%-24s %-10s %s\n", $4, $2, $NF}' | sort -k1,1The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01ssCommandRuns the ss stage of this one-liner.
02-lntpHOptionConfigures ss with the -lntpH option.
03|PipelinePasses the output on the left to the command on the right.
04awkCommandRuns the awk stage of this one-liner.
05'{printf "%-24s %-10s %s\n", $4, $2, $NF}'ArgumentPasses '{printf "%-24s %-10s %s\n", $4, $2, $NF}' to awk.
06|PipelinePasses the output on the left to the command on the right.
07sortCommandRuns the sort stage of this one-liner.
08-k1,1OptionConfigures sort with the -k1,1 option.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
ss -lntpH | awk '{printf "%-24s %-10s %s\n", $4, $2, $NF}' | sort -k1,1
Example output
0.0.0.0:22 128 users:(("sshd",pid=812,fd=3))
127.0.0.1:5432 244 users:(("postgres",pid=1042,fd=7))
[::]:443 4096 users:(("nginx",pid=991,fd=6))
Illustrative output — exact values vary by system and data.
Official sources