I always have to google this and ServerFault is never the first result. Typically I want to do this on a unix box, but I'd also like to know how to do it on a Windows machine from CMD.exe.
Linux – How to show listening open ports from the shell
linuxunixwindows
Related Topic
- SSH – How to Change Private Key Passphrase
- Move Running Process to Screen – How to Do It
- Linux – Check Environment Variables of a Running Process on Unix
- Windows Networking – How to Determine Hostname from IP Address
- Linux – How to Automatically Add New Host to known_hosts
- Linux – How to run a command multiple times, using bash shell
- Linux Web Server – Proper Permissions for Website Files and Folders
Best Answer
Use
netstat -pl
on Unix. Option-p
shows process PID/name and option-l
shows only listen sockets.On Windows, use
netstat -oa
. Option-o
is the same as-p
on Unix. Option-a
is also the same on Unix, it shows all sockets. You'll have to look only at LISTENING lines since Windows' netstat doesn't provide an option to show only listen sockets.If you don't want to resolve IP addresses to name (which can take a great amount of time), use option
-n