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 tcp
If netstat is not install, then you'll be prompted to run the install script
sudo apt install net-tools
Response
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 -ltnp
Generates 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
Related articles
Andrew Fletcher
•
13 Sep 2024
Enforcing HTTPS on an Nginx server: a step-by-step guide
In today's security-conscious world, enforcing HTTPS on your web applications is no longer optional—it's essential. Whether you're dealing with government reports or routine security audits, failing to enforce HTTPS can trigger warnings that leave you scrambling for a solution.In this article, I’ll...
Andrew Fletcher
•
28 Aug 2024
Troubleshooting PHP 8.3 mbstring issues on Ubuntu with Nginx
Maintaining a Drupal site is usually smooth sailing once the environment is properly set up. However, even in a stable environment, updates to modules can sometimes reveal underlying configuration issues that weren't apparent before. This was the case when I updated a contrib module on a Drupal 10.3...
Andrew Fletcher
•
26 Jun 2024
Upgrading Nginx on Ubuntu to due vulnerabilities CVE-2024-32002, CVE-2024-32004 and CVE-2024-32465
The current Nginx version running is 1.18.0. It seems like the Nginx version from the default Ubuntu repositories is still 1.18.0, which might not have the latest security patches. To resolve this, you can add the official Nginx repository to get the latest stable version. 1. Backup your...