Linux provides a rich set of commands for testing network connectivity and assessing transfer rates. Here’s a detailed overview of several key commands that can be utilized for these purposes.
Ping
The ping command checks network connectivity by sending "echo requests" and measuring the response times. It displays how long it took to receive responses and calculates the percentage of requests answered. For example, pinging a local machine might show:
$ ping 192.168.0.11PING 192.168.0.11 (192.168.0.11): 64 bytes from 192.168.0.11: icmp_seq=1 ttl=64 time=4.36 ms
A healthy response typically entails a low response time and 0% packet loss.
Traceroute
The traceroute command traces the path packets take to reach a remote host, showing the time taken for each hop. It helps identify where delays occur. For instance:
$ traceroute www.amazon.comtraceroute to www.amazon.com (99.84.218.165), 30 hops max1 router (192.168.0.1): 1.586 ms2 10.226.32.1: 27.342 ms...
MTR
The mtr (My Traceroute) command combines the capabilities of ping and traceroute to provide a comprehensive picture of network performance, reporting packet loss and latency for each hop:
$ mtr 192.168.0.1
NCAT
The ncat command can check if a specific service is accessible on a given port by sending zero bytes (using the -z
argument):
$ nc -z -v 192.168.0.11 22Ncat: Connected to 192.168.0.11:22.
Speedtest
The speedtest command assesses your internet connection speed, demonstrating the disparity between upload and download speeds. For instance:
$ speedtestDownload: 10.34 MbpsUpload: 1.00 Mbps
Fast
The fast command utilizes Netflix’s speed-testing service to measure download speeds and report average bandwidth over multiple tests.
$ fast10.08 Mbps
Nethogs
nethogs tracks bandwidth usage by process, helping identify applications consuming excessive network resources:
$ nethogs
SS
The ss command provides detailed information about network sockets, revealing active connections and socket states:
$ ss -a -t
IFTOP
The iftop command monitors bandwidth usage in real-time, providing details about ongoing connections and their respective bandwidth utilization:
$ sudo iftop
Ethtool
The ethtool command is useful for interacting with and managing network interface parameters, displaying crucial information about your network interfaces:
$ ethtool wlp1s0
Conclusion
These commands collectively offer a robust toolkit for diagnosing and analyzing network connectivity and bandwidth performance on Linux systems. Whether testing speeds or monitoring utilization, users can leverage these commands for effective network management.