what is the command to check for the ports in linux- sudo netstat

netstat is a powerful networking tool on Linux. In this article, I am going to show you how to install netstat on Debian nine Stretch and how to use netstat to show listening ports on Debian 9 Stretch. Permit'southward become started.

Installing netstat on Debian 9 Stretch:

netstat command is a function of the net-tools utility package on Debian nine Stretch. It may not be installed by default on your Debian 9 Stretch operating system. The net-tools package is available in the official package repository of Debian 9 Stretch. Then installing it is very piece of cake.

First update the apt package repository cache of your Debian 9 Stretch automobile with the following command:

The apt packet repository cache should be updated.

Now run the following command to install the net-tools utility on Debian 9 Stretch:

$ sudo apt install cyberspace-tools

internet-tools should be installed.

Now check whether netstat is working with the following command:

It works!

Listing All Ports and Sockets Using netstat:

You can list all the opened ports and continued sockets on your Debian ix machine with the following command:

or

As you can see, all the opened ports and sockets are listed. It's a very long list.

Listing All the Listening Ports and Sockets with netstat:

You tin can use netstat to see a list of all the ports and sockets that are listening with the post-obit command:

Or

$ sudo netstat --all --listening

As y'all tin can see, all the ports and sockets on your Debian 9 machine is listed. Information technology'south a long listing.

Listing All the Listening TCP Ports with netstat:

Y'all tin list all the TCP (Transmission Control Protocol) ports that are listening using netstat with the following control:

Or

$ sudo netstat --all --listening --tcp

Every bit y'all can see, all the TCP ports that are listening is listed.

In the output of netstat, all the common ports are replaced by the service name by default. For instance, the port 80 by default is the port for the HTTP (HyperText Transfer Protocol), which nosotros all are familiar with. So in the output of netstat, it is shown every bit http instead of port 80 as you can meet in the marked section of the screenshot below.

If yous need the port number, not the service name, then you can run the following netstat control:

Or

$ sudo netstat --all --listening --numeric --tcp

As you can see from the marked section of the screenshot below, the service names are replaced by the port number.

Listing All the Listening UDP Ports with netstat:

If you want to list all the UDP (User Datagram Protocol) ports that are listening on your Debian 9 automobile, yous can exercise so with the following netstat control:

Or

$ sudo netstat --all --listening --udp

All the listening UDP ports should exist listed. Only similar the TCP port case, the mutual port numbers are replaced by the service names by default here as well, as you can run across from the marked section of the screenshot below.

Simply the ports that are not common are not replaced past the service names as you tin run across from the marked section of the screenshot beneath.

If you lot want all the ports to exist displayed, not the service proper name as before, and then run the following netstat control:

Or

$ sudo netstat --all --listening --numeric --udp

As you can come across from the marked section of the screenshot below, the service names are replaced past the UDP port number.

Observe out What Service Name Represent What Port:

Debian 9 Stretch has a service file which can be found at /etc/services

You lot tin open the service file /etc/services with the following command:

The contents of the /etc/services file:

The /etc/services file contains a long list of service name, and the port number and protocol of that specific service that a client or server may use. Programs on Linux system such as netstat uses this file to resolve the port numbers to service names and vice versa.

The service name, port number and protocol of the SSH service in /etc/services file:

How to Get Help with netstat:

On Debian nine Stretch, if yous need any help with the netstat command, you can just go to the manpage of netstat and you should be able to become a clear documentation of what netstat control line options are available and what they practice.

To go to the manpage of netstat, run the following command:

The netstat manpage:

That'due south how you bear witness listening ports on Debian 9 Stretch with netstat. Thanks for reading this article.

About the writer

Freelancer & Linux System Administrator. Also loves Web API evolution with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

howardrefustoo.blogspot.com

Source: https://linuxhint.com/netstat_check_specific_port/

0 Response to "what is the command to check for the ports in linux- sudo netstat"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel