Andrew Fletcher published: 4 August 2022 2 minutes read
Listen in on the ports being used on your server. To do so, run the command
netstat -a | grep tcpIf netstat is not install, then you'll be prompted to run the install script
sudo apt install net-toolsResponse
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
Fetched 196 kB in 1s (332 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 96037 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Run netstat again
This time the response is
tcp 0 0 localhost:postgresql 0.0.0.0:* LISTEN
tcp 0 0 localhost:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN
tcp 0 0 localhost:37609 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 localhost:http-alt 0.0.0.0:* LISTEN
tcp 0 0 localhost:6379 0.0.0.0:* LISTEN
tcp6 0 0 [::]:8983 [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 ip6-localhost:6379 [::]:* LISTEN
Or using
sudo netstat -ltnpGenerates the response
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1006/postgres
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 681/systemd-resolve
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN 769/python3
tcp 0 0 127.0.0.1:37609 0.0.0.0:* LISTEN 1235/uwsgi
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 830/sshd: /usr/sbin
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17560/nginx: master
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1235/uwsgi
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 919/redis-server 12
tcp6 0 0 :::8983 :::* LISTEN 740/java
tcp6 0 0 :::22 :::* LISTEN 830/sshd: /usr/sbin
tcp6 0 0 :::80 :::* LISTEN 17560/nginx: master
tcp6 0 0 ::1:6379 :::* LISTEN 919/redis-server 12