Linux Troubleshooting – netstat command not found in CentOS 7 / RHEL 7

As you probably know, netstat command (network statistics) is a command line tool that can be used to check the network configuration and activity. You can’t find this command in the minimal installation of RHEL 7 and it’s clones like CentOS 7 and Scientific Linux 7. This brief tutorial describes how to get the netstat command working in CentOS 7, RHEL 7 and Scientific Linux 7.

First, we should find out which package provides ‘netstat’ command.

To find out that, run:

yum provides */netstat

Or,

yum whatprovides */netstat

Sample output:

yum provides */netstat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /bin/netstat

As you see in the above output, we need to install net-tools package in order to get netstat command.

So, let us install net-tools command using the following command from the Terminal:

yum install net-tools

Sample output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

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

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

Total download size: 304 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.17.20131004git.el7.x86_64.rpm | 304 kB 00:00:05 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1 
 Verifying : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1

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

Complete!

That’s it. Now you can use the ‘netstat’ command.

netstat

Sample output:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 0 server.ostechnix.com:ssh sk:54534 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] DGRAM 10304 /run/systemd/shutdownd
unix 2 [ ] DGRAM 10242 @/org/freedesktop/systemd1/notify
unix 5 [ ] DGRAM 6104 /run/systemd/journal/socket
unix 13 [ ] DGRAM 6106 /dev/log
unix 3 [ ] STREAM CONNECTED 14013 /var/run/dbus/system_bus_socket
unix 2 [ ] DGRAM 24798 
unix 3 [ ] STREAM CONNECTED 17856 
unix 3 [ ] STREAM CONNECTED 17874 
unix 3 [ ] STREAM CONNECTED 15064

[...]

unix 3 [ ] STREAM CONNECTED 17878 
unix 3 [ ] STREAM CONNECTED 17832 
unix 3 [ ] STREAM CONNECTED 17841 
unix 3 [ ] STREAM CONNECTED 14010 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 14710 /var/run/dbus/system_bus_socket
unix 2 [ ] DGRAM 11594 
unix 3 [ ] STREAM CONNECTED 16500 /run/systemd/journal/stdout
unix 3 [ ] STREAM CONNECTED 17809 
unix 3 [ ] STREAM CONNECTED 17836 
unix 2 [ ] DGRAM 13906 
unix 3 [ ] STREAM CONNECTED 17845

If you find this tutorial useful, share it on your social networks and support us.

You may also like...