Tuesday, 3 January 2017

How To Find Out List Of All Open Ports in Linux

Network Statistics(Netstat) can be used to identify all incoming and outgoing connections in a system.

List out all connections: netstat -a




If we want to display only tcp connections, then 't' option can be used to along with option a.
Similarly 'u' option to display UDP connection details.

When viewing the open/listening port and connections,it's often useful to know the process name/pid which has opened that port or connection.

Note: When using p option, netstat must be run with root privileges.

n -> No reverse dns lookup to speed up the output.
l --> Display only listening(established) connections.
t --> Interested only in tcp connections.
p --> Display who opened those connections.
e --> Display user id




Check if a service is running: use grep with pipe

 

Print netstat output continuously (option c)

netstat -cnt | grep ESTABLISHED













No comments:

Post a Comment