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
•
08 Apr 2025
How smart blocking protects your digital infrastructure
Across every industry, the operational risks of cyber threats are escalating. Automated bots, denial-of-service attacks and vulnerability scanners are increasingly common. For businesses operating in Australia and globally, implementing resilient, proactive security measures is essential to ensure...
Andrew Fletcher
•
06 Jan 2025
How to set up password authentication with Apache or Nginx on Ubuntu
Securing sensitive content is essential for protecting data integrity and user privacy. One effective way to implement security is by restricting access to specific directories or resources using either Apache or Nginx authentication tools. This provides a comprehensive reference for configuring...
Andrew Fletcher
•
21 Nov 2024
How to update your Ubuntu server efficiently
Maintaining your Ubuntu server is essential to ensure it operates smoothly, stays secure, and benefits from the latest features. Whether you're managing a server for personal projects or enterprise-level applications, regularly updating your system is a critical best practice. Here’s a...