Posted: . At: 12:35 PM. This was 10 years ago. Post ID: 7436
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to see if a port is open on a Linux system using netcat.

The netcat command is a program for querying network connections. This little program may be used to query whether a port is open on a Linux system or not.

Here I am determining whether port 443 is open on this Linux Mint machine.

homer@deusexmachina ~ $ nc -zv localhost 443
Connection to localhost 443 port [tcp/https] succeeded!

And it was, I was successful!

If I try to connect to port 22, it will not work as SSH is configured on port 443.

homer@deusexmachina ~ $ nc -zv localhost 22
nc: connect to localhost port 22 (tcp) failed: Connection refused

This trick also works on remote hosts.

homer@deusexmachina ~ $ nc -zv yahoo.cn 443
Connection to yahoo.cn 443 port [tcp/https] succeeded!

So give this a try for yourself, this is very useful, and quicker than an nmap scan.

1 thought on “How to see if a port is open on a Linux system using netcat.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.