In this article, I will explain about the "netstat command not found" error and the steps required to solve this error. netstat is a very popular open source command to check network connections on Linux based Systems. Almost all Linux Professionals are usually aware of this tool. Hence it is very much important to understand the command required to install this tool. I will explain the different commands that you can use on different Linux version to install this tool.
"netstat command not found" error on Linux(RHEL / CentOS, Ubuntu, OpenSUSE )
Also Read: Solved: AH00558: httpd: Could not reliably determine the server's fully qualified domain name
If you have recently setup a fresh Linux Server then probably when you run netstat
command then you get "netstat command not found"
error as shown below.
[root@localhost ~]# netstat -an | grep -i 443 -bash: netstat: command not found
To install netstat command on your RHEL/CentOS based Servers, you need to use yum install net-tools -y command as shown below.
[root@localhost ~]# yum install net-tools -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.piconets.webwerks.in * extras: mirrors.piconets.webwerks.in * updates: mirrors.piconets.webwerks.in Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k Transaction Summary ======================================================================================================================================================================== Install 1 Package Total download size: 306 k Installed size: 917 k Downloading packages: net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1 Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1 Installed: net-tools.x86_64 0:2.0-0.25.20131004git.el7 Complete!
NOTE:
root
user to run all the below commands. You can use any user with sudo
access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo
access to the User.Similarly if you are using any other Linux versions then you need to use below command based on the respective Version to install netstat tool on that Linux Server.
On Debian/Ubuntu Servers
[root@localhost ~]# apt install net-tools
On OpenSUSE Servers
[root@localhost ~]# zypper install net-tools
On Arch Linux Servers
[root@localhost ~]# pacman -S netstat-nat
After successful installation if you again run netstat command and check then you can see it is now working correctly and not showing the previous "netstat command not found"
error as you can see below.
[root@localhost ~]# netstat -an | grep -i 443 tcp6 0 0 :::443 :::* LISTEN
You can also verify the netstat version by using netstat -v
command as shown below. As you can see from below output, netstat is a part of net-tools 2.10-alpha
version.
[root@localhost ~]# netstat -V net-tools 2.10-alpha Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others +NEW_ADDRT +RTF_IRTT +RTF_REJECT +FW_MASQUERADE +I18N +SELINUX AF: (inet) +UNIX +INET +INET6 +IPX +AX25 +NETROM +X25 +ATALK +ECONET +ROSE -BLUETOOTH HW: +ETHER +ARC +SLIP +PPP +TUNNEL -TR +AX25 +NETROM +X25 +FR +ROSE +ASH +SIT +FDDI +HIPPI +HDLC/LAPB +EUI64
You can use netstat --help
command to check all the options available with netstat command as shown below. Also check netstat Man Page for more info.
[root@localhost ~]# netstat --help usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vWnNcaeol] [<Socket> ...] netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay] -r, --route display routing table -I, --interfaces=<Iface> display interface table for <Iface> -i, --interfaces display interface table -g, --groups display multicast group memberships -s, --statistics display networking statistics (like SNMP) -M, --masquerade display masqueraded connections -v, --verbose be verbose -W, --wide don't truncate IP addresses -n, --numeric don't resolve names --numeric-hosts don't resolve host names --numeric-ports don't resolve port names --numeric-users don't resolve user names -N, --symbolic resolve hardware names -e, --extend display other/more information -p, --programs display PID/Program name for sockets -o, --timers display timers -c, --continuous continuous listing -l, --listening display listening server sockets -a, --all display all sockets (default: connected) -F, --fib display Forwarding Information Base (default) -C, --cache display routing cache instead of FIB -Z, --context display SELinux security context for sockets
Popular Recommendations:-
5 Examples to Turn Off SELinux Temporarily or Permanently on RHEL 8/CentOS 8
Useful C Program to List Network Interfaces using only 30 Lines of Code
Best Explanation of Wrapper Classes in Java: Autoboxing and Unboxing with Examples
5 Best Ways to Become root user or Superuser in Linux (RHEL/CentOS/Ubuntu)
How to Install PHP on RedHat/CentOS 7 with Easy Steps
7 Easy Steps to Install PHP on RHEL 8/CentOS 8