Networking is a fundamental part of any Linux system, whether you’re working on a personal laptop or administering hundreds of servers. From diagnosing connection issues to monitoring real-time network traffic, Linux provides a powerful set of command-line tools to help you understand and troubleshoot what’s going on under the hood. This guide explores 10 essential networking commands every Linux user should know. With clear explanations and practical examples, you’ll learn how to trace packets, resolve DNS issues, inspect interfaces, and monitor bandwidth—all from the terminal.
1. ping — Test Network Connectivity
ping is the simplest way to check whether a host is reachable and how long packets take to travel. It sends ICMP echo requests and waits for replies.
$ ping google.com PING google.com (142.250.183.206) 56(84) bytes of data. 64 bytes from maa03s26-in-f14.1e100.net: icmp_seq=1 ttl=114 time=15.3 ms
Use -c to limit the number of packets: ping -c 4 example.com. If the host doesn’t reply, it may be down or blocked by a firewall.
2. traceroute — Track the Path to a Host
traceroute shows the path your packets take to reach a destination, including delays at each hop. It’s great for diagnosing where in the network a delay or drop is occurring.
$ traceroute example.com 1 router.local (192.168.1.1) 1.123 ms 2 isp-gateway.net (10.0.0.1) 5.344 ms 3 example.com (93.184.216.34) 20.112 ms
If you see * * * in the output, it indicates a timeout or firewall blocking ICMP on that hop.
3. ip a — Show Network Interfaces and IPs
ip a (or ip addr) lists all network interfaces and their assigned IP addresses. It replaces the older ifconfig and provides more detailed output.
$ ip a 2: enp0s3:mtu 1500 inet 192.168.1.50/24 brd 192.168.1.255 scope global dynamic enp0s3
Look for UP status to verify whether the interface is active, and note the IP address assigned under inet.
4. ip r — View Routing Table
The ip route or ip r command displays your system’s routing table, showing where packets go by default or to specific subnets.
$ ip r default via 192.168.1.1 dev enp0s3 192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.50
This is crucial when dealing with multi-interface setups or checking if the default gateway is correct.
5. ss — Show Open Sockets and Ports
ss is a modern replacement for netstat, used to inspect open ports, sockets, and connections on your machine.
$ ss -tuln Netid State Local Address:Port Peer Address:Port tcp LISTEN 0.0.0.0:22 0.0.0.0:* udp UNCONN 127.0.0.1:323 0.0.0.0:*
Use -tuln to show TCP/UDP ports, in numeric form. Replace with -p to view the processes using the ports.
6. dig — Perform DNS Lookups
dig is a flexible DNS query tool. It can be used to test if a domain resolves properly, inspect records, and debug DNS configuration.
$ dig openai.com ;; ANSWER SECTION: openai.com. 300 IN A 104.18.12.123 openai.com. 300 IN A 104.18.13.123
Try dig +short openai.com for a simplified output. It’s also useful for querying specific record types like MX, TXT, or NS.
7. host — Simple DNS Lookup
host is a simpler alternative to dig. It resolves a domain name into its IP address, or does a reverse lookup.
$ host github.com github.com has address 20.205.243.166 $ host 8.8.8.8 8.8.8.8.in-addr.arpa domain name pointer dns.google.
This is useful for quick DNS checks without the detailed output that dig gives.
8. curl — Test HTTP Requests
curl is commonly used to test HTTP/HTTPS endpoints directly from the terminal. It supports headers, POST data, authentication, and more.
$ curl -I https://example.com HTTP/2 200 date: Sat, 06 Jul 2025 13:12:42 GMT content-type: text/html
Use -I for headers only, or -v for verbose connection details. It’s great for API testing and monitoring server status.
9. nmap — Network Port Scanner
nmap is a powerful tool for scanning hosts to detect open ports, services, OS types, and vulnerabilities. It’s widely used by sysadmins and security professionals.
$ nmap -sT -p 22,80,443 192.168.1.50 Starting Nmap... PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp closed https
Try nmap -sn 192.168.1.0/24 to ping-scan your entire subnet and find active devices.
10. iftop — Real-Time Bandwidth Monitor
iftop displays bandwidth usage per connection in real time. It’s like top but for network interfaces. Very useful for identifying what process or destination is using your bandwidth.
$ sudo iftop -i enp0s3
Use arrow keys to sort and filter. iftop doesn’t show process names—use nethogs if you need process-level insight.
Conclusion
With these 10 Linux networking commands, you can diagnose and monitor virtually any network-related issue. Whether you’re resolving DNS problems with dig, checking interface configurations with ip a, monitoring bandwidth usage with iftop, or scanning a remote machine with nmap, the Linux CLI gives you everything you need for troubleshooting and insight. These commands are not just tools—they’re essential skills that every Linux administrator and power user should have in their toolbox.
Pro tip: Save common diagnostic sequences in shell scripts for reuse. You can also add aliases like alias netcheck="ping -c 4 google.com && ip a && ip r" to quickly verify connectivity issues. With just a few keystrokes, you’ll be able to pinpoint problems and resolve them faster than ever before.