Reputation: 13491
In a Linux specific way, how can I get the list of all open UDP ports and all TCP ports currently accepting connections in some interface?
Upvotes: 2
Views: 1322
Reputation: 379
List all listening processes and what port they are listening too. Running without sudo will list only user processes.
sudo ss -tlpn
explanation:
-t
tcp-l
listening-p
show process-n
numeric, don't replace port numbers with their "popular" name.Upvotes: 0
Reputation: 229
The most common way is to use netstat console utility with the following flags:
netstat -plan
where:
-p : Show the PID and name of the program to which each socket belongs;
-l : Show only listening sockets;
-a : Show both listening and non-listening sockets;
-n : Show numerical addresses instead of trying to determine symbolic host, port or user names.
For additional output options and flags please check man pages man netstat
. Based on your particular needs, only TCP or UDP (for example) protocol connections can be examined:
netstat -4 --tcp --udp --all
Alternatively, lsof -i
might be helpful.
Most likely you are interested in the following information (special /proc filesystem):
/proc - Mount point for the proc filesystem, which gives access to kernel status information via the following files:
Upvotes: 5