Introduction
This article covers checking which service, if any, is bound to a port.
Procedure
The following commands will check for services bound to a port, where PORT is replaced with the actual port number. Note that Netstat has been deprecated in favor of SS.
ss -plntu|grep :PORT
netstat -plnt|grep :PORT
For example, we can see that PowerDNS is bound to port 53 in the examples below. Note that IP 0.0.0.0 and * indicate that the service is bound to the port on all IPv4 IPs, and :: means this for IPv6.
[root@hostname ~]# ss -plntu|grep :53
udp UNCONN 0 0 *:53 *:* users:(("pdns_server",pid=2761,fd=5))
udp UNCONN 0 0 :::53 :::* users:(("pdns_server",pid=2761,fd=6))
tcp LISTEN 0 128 *:53 *:* users:(("pdns_server",pid=2761,fd=7))
tcp LISTEN 0 128 :::53 :::* users:(("pdns_server",pid=2761,fd=8))
[root@hostname ~]# netstat -plntu|grep :53
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 2761/pdns_server
tcp6 0 0 :::53 :::* LISTEN 2761/pdns_server
udp 0 0 0.0.0.0:53 0.0.0.0:* 2761/pdns_server
udp6 0 0 :::53 :::* 2761/pdns_server
If no output is returned, then there is no service bound to that port and the service that should be bound will need to be restarted. The examples below show what this will look like.
[root@hostname ~]# ss -plntu|grep :1234
[root@hostname ~]#
[root@hostname ~]# netstat -plntu|grep :1234
[root@hostname ~]#
Related articles:
How do I know if a process is running or working?
What are the basic Linux command line/terminal commands to know?
Using Terminal To Access the Command Line
Comments
0 comments
Article is closed for comments.