Essential Linux Commands to Diagnose and Fix Network Issues
This guide introduces the ten most commonly used Linux commands for network troubleshooting—such as ping, traceroute, netstat, ifconfig, ip, ss, dig, mtr, nmap, and iperf—explaining their purpose, key options, and practical usage examples to help quickly locate and resolve connectivity problems.
In Linux environments, network connectivity problems are a frequent challenge for both system administrators and regular users. Understanding how to quickly diagnose and resolve these issues is essential. This article presents the ten most commonly used Linux commands for checking network problems, detailing their functions, key parameters, and example usages.
ping command
The ping command is a fundamental network diagnostic tool that tests connectivity to a target host by sending ICMP echo requests and waiting for replies, allowing users to verify reachability and measure latency.
Usage example:
ping example.comThis sends ICMP echo requests to example.com and displays the response time for each request.
traceroute command
The traceroute command traces the path packets take from the local host to a destination host by sending a series of UDP packets and showing each hop (router) along with its response time, helping identify latency and packet loss along the route.
Usage example:
traceroute example.comThis displays the network path to example.com and the response time of each hop.
netstat command
The netstat command displays various network-related information, including active connections, routing tables, and interface statistics, enabling users to understand current network activity and locate connection issues.
Usage example:
netstat -tulnThis shows all TCP and UDP listening sockets on the system.
ifconfig command
The ifconfig command configures and displays network interface information, such as IP address, subnet mask, and MAC address, helping users inspect interface settings and diagnose connectivity problems.
Usage example:
ifconfigThis lists the configuration of all network interfaces on the system.
ip command
The ip command is a powerful network configuration tool that can display and modify interface settings, routing tables, and ARP caches. Compared with ifconfig, it offers greater flexibility and is preferred for advanced network management.
Usage example:
ip addr showThis shows the IP addresses and status of all network interfaces.
ss command
The ss command provides detailed socket statistics, including TCP, UDP, and UNIX domain sockets. It offers similar information to netstat but with higher efficiency and flexibility, allowing rapid inspection of active connections.
Usage example:
ss -tulnThis displays all listening TCP and UDP sockets, similar to netstat -tuln.
dig command
The dig command queries DNS information, enabling users to resolve domain names, view name servers, and retrieve IP addresses, which is useful for diagnosing DNS-related connectivity issues.
Usage example:
dig example.comThis queries the DNS records for example.com, showing IP addresses, name servers, and related data.
mtr command
The mtr command combines the functionality of traceroute and ping, providing a real‑time view of the packet path and statistics such as loss rate and latency for each hop.
Usage example:
mtr example.comThis displays the network path to example.com while continuously reporting packet loss and latency per hop.
nmap command
The nmap tool scans a target host to discover open ports and services, helping identify potential security issues by revealing which services are reachable.
Usage example:
nmap -p 1-1000 example.comThis scans ports 1 through 1000 on example.com and lists any open ports and their associated services.
iperf command
The iperf utility measures network performance between two hosts, reporting bandwidth, latency, and packet loss, which is valuable for pinpointing performance bottlenecks.
Usage example:
iperf -c server_ipThis runs iperf in client mode, testing the connection to the specified server IP.
Conclusion
The ten commands— ping, traceroute, netstat, ifconfig, ip, ss, dig, mtr, nmap, and iperf —cover network diagnostics, route tracing, port scanning, and performance testing. Mastering their usage enables users to quickly locate and resolve a wide range of network connectivity issues, improving efficiency and accuracy in system administration.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
