With this post you will also learn, how to find RPM packages which has certain command or files.
You may have encounter with the error like “netstat command not found” on Red Hat based operating system. This time, on exploring and using CentOS 7, I found many changes. Generally I prefer to go with minimal installation of any operating system. It gives me chance to learn many things and helps me to understand the operating system.
NOTE: The method is applicable to CentOS 5/6/7 and RHEL 5/6/7
The post is about “netstat command not found” but it is also applicable to cases where other commands are also not found. It is hard to remember which rpm package provide which command on operating system. Here , we are keeping things simple.
yum command which is preinstalled on CentOS/RHEL has awesome arguement called provides . Here we will use this syntax
yum provides */package-name-or-file-name
Here, we are looking for command called netstat
. Hence, as per above given syntax
Use the command –
yum provides */netstat
Form above command, I got the output that net-tools package is required for netstat command. Hence, install net-tools package by using yum command.
yum install net-tools
After successful installation of net-tool package. Check the netstat command. I believe it is working now.
Below given is reference from my system. How I used the commands.
[root@localhost ~]# yum provides */netstat Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.aol.in * extras: centos.aol.in * updates: centos.aol.in ctdb-tests-2.5.1-2.el7.x86_64 : CTDB clustered database test suite Repo : base Matched from: Filename : /usr/share/ctdb-tests/eventscripts/stubs/netstat net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools Repo : base Matched from: Filename : /bin/netstat [root@localhost ~]# [root@localhost ~]# yum install net-tools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.aol.in * extras: centos.aol.in * updates: centos.aol.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:11 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! [root@localhost ~]#