commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
in loop, until the last port (65535), list all opened ports on host.
in the sample I used localhost, but you can replace with any host to test.
There are 3 alternatives - vote for the best!
While `lsof` will work, why not use the tool designed explicitly for this job?
(If not run as root, you will only see the names of PID you own)
Alternative of OJM snippet :
This one show the IP too, where ports bind. It's very important, because if there's only 127.0.0.1 instead of 0.0.0.0, connections from internet are rejected.
If you can do better, submit your command here.
You must be signed in to comment.