netstat Command not found on CentOS 8 / RHEL 8 – Quick Fix

0

netstat is a command-line utility to view network connections information to/from the machine. With netstat command, you can see network connections, interface statistics, routing tables, masquerade connections, and multicast memberships.

Are you wondering? netstat command not found after the installation of CentOS 8 / RHEL 8.

READ: How To Install CentOS 8 (With Screenshot)

READ: How To Install RHEL 8 (With Screenshot)

-bash: netstat: command not found

Install netstat Package

This post will help you to install the necessary packages for getting netstat command.

Let us see which package provides us with the netstat command.

yum whatprovides netstat

Output:

CentOS-8 - AppStream                                                            1.2 MB/s | 5.6 MB     00:04
CentOS-8 - Base                                                                 1.5 MB/s | 5.3 MB     00:03
CentOS-8 - Extras                                                               567  B/s | 2.1 kB     00:03
Elasticsearch repository for 7.x packages                                       754 kB/s | 3.4 MB     00:04
Extra Packages for Enterprise Linux 8 - x86_64                                  515 kB/s | 2.0 MB     00:03
Last metadata expiration check: 0:00:01 ago on Wed 25 Sep 2019 06:26:50 AM EDT.
net-tools-2.0-0.51.20160912git.el8.i686 : Basic networking tools
Repo        : BaseOS
Matched from:
Filename    : /usr/bin/netstat

net-tools-2.0-0.51.20160912git.el8.x86_64 : Basic networking tools
Repo        : BaseOS
Matched from:
Filename    : /usr/bin/netstat

From the above command, you could see that the net-tools package provides you netstat command. So, install the net-tools package using the yum command.

yum -y install net-tools

Output:

Last metadata expiration check: 0:03:09 ago on Wed 25 Sep 2019 06:26:50 AM EDT.
Dependencies resolved.
================================================================================================================
 Package                 Arch                 Version                                Repository            Size
================================================================================================================
Installing:
 net-tools               x86_64               2.0-0.51.20160912git.el8               BaseOS               323 k

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

Total download size: 323 k
Installed size: 1.0 M
Downloading Packages:
net-tools-2.0-0.51.20160912git.el8.x86_64.rpm                                   1.4 MB/s | 323 kB     00:00
----------------------------------------------------------------------------------------------------------------
Total                                                                           183 kB/s | 323 kB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                        1/1
  Installing       : net-tools-2.0-0.51.20160912git.el8.x86_64                                              1/1
  Running scriptlet: net-tools-2.0-0.51.20160912git.el8.x86_64                                              1/1
  Verifying        : net-tools-2.0-0.51.20160912git.el8.x86_64                                              1/1

Installed:
  net-tools-2.0-0.51.20160912git.el8.x86_64

Complete!

Important netstat Examples

Execute the netstat command to see whether the command is available on your machine or not.

The netstat command with no extra option will only display the listening sockets.

netstat
netstat Command
netstat Command

Use -a option with the netstat to display both listening and non-listening sockets.

netstat -a
All Statistics
All Statistics

Use -n option with the netstat to display IP address instead of hostname.

netstat -n
Display IP Address
Display IP Address

Use -t with -an to display all TCP connections.

netstat -ant
Display TCP Connections
Display TCP Connections

Use -u with -an to display all UDP connections.

netstat -anu
Display UDP Connections
Display UDP Connections

Use -p additionally to any of the above options to display the PID and name of the program to which each connection belongs.

netstat -anp
Display Application Details
Display Application Details

Use -nr option with netstat command to display route details.

netstat -nr
Route Details
Route Details

Conclusion

That’s All. You now have learned how to get back netstat command and use it on your CentOS 8 / RHEL 8 machine.

You might also like