During the troubleshooting of offerings strolling on a Linux system, checking open ports is one of the obligations any consumer or administrator have to bear in mind performing. If a carrier is predicted to be strolling however for a few motive it is not, then maximum probably the port related to that carrier is closed and have to be opened. In this tutorial, we are able to exhibit how to test open ports in a Linux from the command line.
Check open ports with the use of ss command
The Linux ss command offers you designated insights on open ports and listening sockets. It attracts facts from the Linux kernel and is greater favored to the netstat command which has been deprecated.
$ ss -tl
Sample output
l – Shows listening sockets
t – Stands for TCP port
To display listening UDP connections, issue the command
$ ss -lu
Sample output
u – Stands for UDP port
or
To display both tcp and udp, process name
$ ss -lntup
p – List process name that opened sockets
To print out all socket connections, simply use the ss command in its default format
$ ss
Sample output
Check open ports using netstat command
The netstat command is a effective command device this is used for checking open TCP and UDP ports along different attributes. To take a look at open ports, difficulty the command:
$ netstat -pnltu
Let’s take a better have a take a observe the command options:
p – Displays the Procees ID related to a provider or Program name
n – Displays the numerical variety of the port walking e.g 3306 for mysqld, and 22 for sshd.
l – Shows listening sockets
t – Displays TCP connections
u – Displays UDP connections
Check open ports the usage of the lsof command
The lsof command is a community command toolthat also can be used to test open ports in a Linux system. To show open ports, difficulty the command
$ lsof -i
Sample output
If you wish to display open sockets, use the lsof
command and pipe the output to grep as shown:
$ lsof -n -P | grep LISTEN
Sample output
To view all TCP connections execute :
$ lsof -i tcp
Sample output
To display all UDP connections run the command:
$ lsof -i udp
Sample output
Conclusion
Those are the linux instructions and equipment used for port scanning to test open ports in a Linux system. As always, your comments is most welcome. If you’ve got got different thoughts on how to test open ports, do get in contact with us.
Also Read : How to install Lynis Security Auditing tool in Ubuntu
How to setup Docker-Compose in Ubuntu 20.04
How to find when a Linux file is created (Super Geeky Stuff)
Tags:
open port linux, check open ports linux, ubuntu open port, linux list open ports, netstat, ss command, ss command linux, lsof command, lsof command linux, check if port is open linux, ubuntu check open ports, linux open port command, list ports in use linux |
---|