Unix and linux open port guide

This Unix and Linux open port guide will try to show you how to get the current open ports on a Linux or Unix box. I am using CentOS 7 for the screen. You need to be familiar with some build in command line tools.

Linux Open Port
Linux Open Port

Here are the command i will talk about in this guide: netstat, iptables, lsof, telnet, and nmap. Once you get to know basic use with the tool you will be able to check for open ports on Linux.

If, for example, you are familiar with windows and need to check if port is open on Linux box you need to read this. In here you will see the command line needed to do that.

Command line tool related to Linux open port:

As we are working on a Linux box i want you to be comfortable and familiar with the command help system. We can use the ‘–help’ in most of the command to get some help about the command.
Another great option to get help for a command is using the ‘man’ command (manual).

Here are the Linux command line i will talk about:

  • Netstat – Netstat is a network status or statistic command line tool that can show you a list of open ports, there status and some more information.
  • iptables – Build in firewall, using this command you can control the Linux firewall.
  • lsof – Command line tool to list open files.
  • telnet/ssh – A small tool, that can do a connection using a port and ip. if you manage to connect the remote port is open.
  • nmap – Nmap the network mapper can be used to scan a subnet of IP with lots of ports and get their status. It supports some types of connection: SYN, ACK, and more. Please refer to nmap help for more information. Nmap is an external tool that you can install from nmap.

Command usage for Linux open port:

A quick guide to use the above command now that you know them, here are the command to check open ports in Linux.

Linux netstat command:

Using netstat command line on Linux you can easily get a list of all the open ports on you system.

The netstat command contain several switches that yo can use to control what it show you.

Please note, you need to be root user to use the full power of the netstat command.

Here is an example to get all the port base on port number:

netstat -anp | grep <PORT NUMBER>


  • a  – Display all sockets.
  • n – Don’t resolve names – show as port number (do not make 80 -> http as example).
  • p – Display PID/Program/process name for sockets.

Here is an example that list all the ports that contain 80 in them:

netstat -anp | grep 80

And here how it looks in the system:

 Netstat linux open port
Netstat Linux open port

Linux lsof command line:

The lsof command line tool can show you list of open files on a Linux box.

If you combine this command line with the -i option, it can show you open files that open a socket to the internet.

The -i option can also have some tweak, and here they are:

To get all sockets with TCP or UDP connection use the following command:

For TCP: lsof -i tcp

For UDP: lsof -i udp

You can also add the port number to find the associated service:

lsof -i :5000

Please note the colon : in the lsof command line.

And here is an example of the command:

linux open port using lsoc
Linux open port using lsoc

The iptables command line:

Cisco ireless N VPN Firewall Router
Cisco RV110W-A-NA-K9 Small Business RV110W Wireless N VPN Firewall Router

You can think on the iptables as a configuration utility for the Linux kernel firewall an implemented within the Netfilter project. Give an administrator the option to add network filters base on network protocol.

You can use iptables to inspect, modify, forward, redirect, and/or drop IPv4 packets (there are also other implementation to support IPv6.

Please refer to Wikipedia or wiki.archlinux.org for more information on iptables, but for our use here is what you need to know.

When you use the -L parameter in iptables it list the current configure rules in it.

if you add the -n parameter you can get a list same -L info but with numeric output for the ports and the addresses.

Here is part of an ‘iptables -L -n’ command:

iptable Linux open port
The iptables Linux command output

If you want to see more information you can use the following iptables command:

iptables -nvL


  • -L List the rules in a chain or all chains.
  • -n Numeric output of addresses and ports
  • -v verbose mode, under Linux verbose mode will print extra information to the screen.

Please note, under Linux case is sensitive, means -A is not the same as -a, keep that in mind.

The Linux telnet/ssh command line:

Telnet is a small client and server sides tool that was very common in the past. This is due to the fact that its working in plain text, no encryption.

This is also the reason you will not find it install as default on modern Linux box.

The SSH is the replacement for telnet, it is build in on most of Linux boxes and it use secure socket to communicate – traffic is encrypted.

  • Telnet default port is 21
  • SSH default port is 22
  • Both are configurable.

But, if you want to use them as a Linux port checker you just need to set them the remote address and port to use:


telnet openport.net 443

ssh open port.net 443


And here is a screen:

Telnet and ssh Linux open port
Telnet Linux open port

BTW, if you getting a message that you cant use the telnet command. You can install telnet on your Linux box if it connected to the internet. You also need to be root.

yum install telnet -y

The nmap command line tool:

The nmap tool is a free port mapper tool that you can use to check if Linux port open, this is in related to our article.

Nmap is much more then a port checker, it is a tool that capable to scan full subnet use sophisticated protocol and gives you the operation system and service that you try to scan.

It is a port scanner that can be very helpful to test and troubleshoot network issues.

Here is an example:

nmap openport.net -p 443


And here is a screen:

nmap linux open port
nmap Linux open port

Please look on nmap help to get more cool nmap options, you can also look on nmap website (and yes, there is also version for windows box).

nmap -h

BTW, if you getting a message that you cant use the nmap command. You can install nmap on your Linux box if it connected to the internet. You also need to be root.

yum install nmap -y

Well, i do hope this article gives you some of the basic knowledge regarding Linux open port how to see them using some command line tools.

Please share this articles with your friends if you like it and also please check our front page for an online open port checker tool and other useful information.

1 thought on “Unix and linux open port guide”

Leave a Comment

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