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
•
27 Oct 2023
Using OpenAI to summarise PDF
To use OpenAI to summarise text from a PDF using Python 3.11.6, you'll first need to extract the text from the PDF and then send it to the OpenAI API for summarisation. Preparation Set-uppip install python-dotenv langchain openai tiktoken pypdf pymupdf CodeThe current code is on my...
Andrew Fletcher
•
20 Oct 2023
PermissionError: [Errno 13] Permission denied
Permission errorTraceback (most recent call last):
File "/var/www/html/open-ai/summarise-ai.py", line 144, in <module>
getfiles()
File "/var/www/html/open-ai/summarise-ai.py", line 26, in getfiles
summarise(filename)
File "/var/www/html/open-ai/summarise-ai.py", line 105, in...
Andrew Fletcher
•
19 Oct 2023
How to add an environment variable in Ubuntu
To set an environment variable on Ubuntu, can be achieved via a few options. This depends on whether you want the variable to be system-wide or specific to a user's session. Here are a couple of more common methods for setting environment variables:Setting environment variables for the...