Answered by the Webhosting Experts

Checking What Ports Are Listening On a Server

Linux server ports are communication endpoints that allow different services to run on a Linux system. They are identified by a number from 0 to 65535 and a protocol such as TCP or UDP. Some ports are reserved for well-known services, such as port 22 for SSH and port 80 for HTTP. Other ports are available for user-defined services or applications. 

To review which ports the server is listening to, use the following methods.

Netstat

Netstat is a command-line tool that displays network statistics for all active connections on a computer. It can help troubleshoot network problems by showing the protocol, local and foreign address, and state of each connection. Netstat can also show the network adapter and protocol statistics, as well as the IP routing table.

Use the following command to view which ports are being used:

netstat –listen

Screenshot showing the results of the netstat --listen command.

You can also use sudo netstat -tulpn | grep LISTEN for specific results for listening activities.

Screenshot showing the results of the sudo netstat -tulpn | grep LISTEN command.

lsof Command

The lsof command is a useful tool for Linux system administrators. It stands for list open files and it can show information about files that are opened by processes on the system. Everything in Linux is treated as a file, so lsof can also display information about devices, sockets, pipes, directories, and more. You can use various options with lsof to filter the output by user, process, file system, network connection, port number, etc. 

Use the following command to view ports being used.

lsof -i

Screenshot showing the results of the lsof -i command.

You can also use sudo lsof -i -P -n | grep LISTEN for specific results for listening activities.

Screenshot showing the results of the sudo lsof -i -P -n | grep LISTEN command.

ss Command

The ss command is a Linux utility that displays information related to network connections. It can show more details than the classic netstat command, such as TCP and UDP sockets, Unix sockets, ICMP sockets, and raw sockets. You can use ss to monitor and troubleshoot your network connections with various options and filters.

Use the following command to view ports being used.

sudo ss -tulpn

Screenshot showing the results of the sudo ss -tulpn command.

You can also use sudo ss -tulpn | grep LISTEN for specific results for listening activities.

Screenshot showing the results of the sudo ss -tulpn | grep LISTEN command.

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here at: support@hivelocity.net. We are also available to you through our phone and live chat system 24/7/365.