How to install netstat in linux centos

Posted in Linux May 21, 2018

If you are a regular Linux user and need to deploy many Vms in the cloud service providers like , Linode or Digital Ocean , then you will need to debug most of the time and since these are the cheap providers you tend to debug them yourself , one of the most common tool is netstat so people normally find it difficult to use it as at times these tools are not installed by default, so this is the way to install netstat in Linux systems ( centos 6 , centos 7 )

yum epel-release -y yum install net-tools -y
Once you install these you shall get the following screen in your console
[root@sangv.info ~]# yum install net-tools -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.millry.co
 * epel: sjc.edge.kernel.org
 * extras: mirrors.tummy.com
 * updates: repos.lax.quadranet.com
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                         Arch                                         Version                                                           Repository                                  Size
=================================================================================================================================================================================================================
Installing:
 net-tools                                       x86_64                                       2.0-0.22.20131004git.el7                                          base                                       305 k

Transaction Summary
=================================================================================================================================================================================================================
Install  1 Package

Total download size: 305 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm                                                                                                                                             | 305 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.22.20131004git.el7.x86_64                                                                                                                                                     1/1
  Verifying  : net-tools-2.0-0.22.20131004git.el7.x86_64                                                                                                                                                     1/1

Installed:
  net-tools.x86_64 0:2.0-0.22.20131004git.el7

Complete!
This is one of the ways to do it , so here is one fo the example you can use for netstat to listen the ports , or the ports in the server which are in LISTEN Mode
netstat -tulpn
[root@sangv.info ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1947/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 11144/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2446/master
tcp6 0 0 :::80 :::* LISTEN 10554/httpd
tcp6 0 0 :::22 :::* LISTEN 11144/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2446/master
udp 0 0 0.0.0.0:44905 0.0.0.0:* 3289/dhclient
udp 0 0 0.0.0.0:68 0.0.0.0:* 3289/dhclient
udp 0 0 127.0.0.1:323 0.0.0.0:* 20202/chronyd
udp6 0 0 :::53314 :::* 3289/dhclient
udp6 0 0 ::1:323 :::* 20202/chronyd
This result should the ports that re open for the servers to operate your needs

sangv. Info