Sometimes you might need to test whether a specific port is open in Linux based on your firewall rules. Without having to install specific software (e.g, telnet server for port 21) you can test this using netcat.
This can be handy if you need to prove to a service provider that they are blocking your ports.
Example, port 21
On the server side:
For ports under 1000 you must be root/sudo user
sudo netcat -l 21
On the client side
netcat [server ip] 21
It will look like nothing has happened. On the client side, just type some random words, e.g. “Hello World!” and hit [ENTER]. If the connection was successful, you should see the same words echoed on the server side.
To end the session you can either use CTRL+C on the server side (will kill both sides) or CTRL+D on the client side (will only kill the client side)