List all listening ports
Read-only
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Shows every TCP port with a listening process on the local machine, with the owning process for each, without changing any network state.
networkportprocessinspect
Commands
List every listening TCP socket with its owning process
lsof -nP -iTCP -sTCP:LISTENVerification
lsof -nP -iTCP -sTCP:LISTENA table of listeners is shown; an empty result means nothing is listening.
Undo
Not undoable
This recipe only reads socket information and changes nothing.
Pitfalls
- Process names for sockets owned by other users may be hidden unless the command is run with elevated privileges.
- On Linux, ss -tlnp only shows process names when run as root; without it the process column is empty.
- The verification command uses macOS syntax; on Linux use "ss -tlnp" and on Windows "Get-NetTCPConnection -State Listen".