In this tutorial, we’re going to teach you how to keep your windows operating system secure. This method can be used in Windows, Linux or mac doesn’t matter because that tool is pre-installed.
Let’s get started! Open up you’re terminal or in windows open your CMD and type:
There are few parameters to netstat that are useful for this :
- -l or –listening shows only the sockets currently listening for an incoming connection.
- -a or –all shows all sockets currently in use.
- -t or –TCP shows the TCP sockets.
- -u or –UDP shows the UDP sockets.
- -n or –numeric shows the hosts and ports as numbers, instead of resolving in DNS and looking in /etc/services.
You use a mix of these to get what you want. To know which port numbers are currently in use, use one of these:
netstat -atn # For tcp netstat -aun # For udp netstat -atun # For both
In the output all ports mentioned are in use either listening for incoming connection or connected to a peer** all others are closed. TCP and UDP ports are 16 bits wide (they go from 1-65535)
You can use this command:
netstat -tulnp | grep <port no>
If it shows some process it’s used. It’s closed (not used) if there is no output.