Count established TCP connections
Build a paste-ready command, then review its compatibility and effects before running it.
ss -H state established | wc -lread-onlyno known side effects Compatibility
LinuxUses the Linux ss utility.
Operational knowledgereview due 2027-01-19
Requirementsssss must be installed and available on PATH.
Version supportss Current supported releasesVerified for linux using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals17Representative 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 -H state established | wc -lThe 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-HOptionConfigures ss with the -H option.
03stateArgumentPasses state to ss.
04establishedArgumentPasses established to ss.
05|PipelinePasses the output on the left to the command on the right.
06wcCommandRuns the wc stage of this one-liner.
07-lOptionConfigures wc with the -l option.
Example input
ss -H state established | wc -l
Illustrative output — exact values vary by system and data.
Official sources