Whether you are setting up a server at home, managing a small local area network, or simply enjoy tinkering with Linux systems, these commands are worth mastering. Learning them will significantly enhance your network debugging and analysis capabilities.
1. <span>iftop</span> — The “Speedometer” of Network Traffic
If you have used <span>top</span> to check CPU and memory usage, then <span>iftop</span> is its network version. It displays the bandwidth usage of each network connection in real-time, allowing you to quickly see who is “eating” your internet speed.
Usage Example:
Suppose you are running a Minecraft server on a Linux server, and players have recently complained about latency. You can run:
iftop -i eth0
Where <span>-i eth0</span> indicates listening on the wired network card (if it’s Wi-Fi, change it to the corresponding network card name).
After running, you might see:
192.168.1.10 ⇄ 203.0.113.5 3.5Mb 3.4Mb 3.6Mb
192.168.1.10 ⇄ 93.184.216.34 200Kb 100Kb 150Kb
192.168.1.10 ⇄ 142.250.191.206 1.50Mb 1.60Mb 1.55Mb
Clearly, the player at 203.0.113.5 is consuming a lot of bandwidth, possibly downloading resource packs. With this data, you can target your troubleshooting efforts.
2. <span>mtr</span> — Intelligent Ping + Route Tracing
<span>mtr</span> is a combination of <span>ping</span> and <span>traceroute</span>, which can display the latency and packet loss at each hop along the network path in real-time. It acts like GPS for the internet, telling you not only where the “road” is but also which segment is congested.
Usage Example:
If you frequently disconnect while gaming and suspect a network issue, you can run:
mtr -rw game.example.com
The result might be:
Host Loss% Snt Last Avg Best Wrst
1. 192.168.1.1 0.0% 10 2.0 1.5 1.0 2.5
2. 10.100.0.1 0.0% 10 5.0 5.3 4.9 6.1
3. isp-gateway.net 0.0% 10 25.1 24.8 24.3 26.0
4. ***.backbone.com 60.0% 10 100+ 110+ - -
Seeing a 60% packet loss at hop 4, the issue is basically pinpointed.
3. <span>nmcli</span> — The Network Control Center in the Terminal
<span>nmcli</span> is the command-line tool for NetworkManager, allowing you to manage network connections without a graphical interface.
Usage Example:
To connect to Wi-Fi on an Ubuntu Server without a desktop environment:
nmcli device wifi list
nmcli device wifi connect "WiFi Name" password "Password"
To view saved network configurations:
nmcli connection show
To delete an unused network:
nmcli connection delete "OldWiFi"
For server maintenance, <span>nmcli</span> can help you quickly complete network configurations and troubleshooting.
4. <span>dnstop</span> — Real-time Monitoring of DNS Traffic
Want to know which websites your computer (or other devices on the network) are accessing?<span>dnstop</span> can listen to DNS query requests and display the results in real-time.
Usage Example:
Run:
dnstop eth0
You might see:
Queries by name:
127 youtube.com
92 spotify.com
54 facebook.com
This way, you can discover if there are any abnormal domain resolution behaviors in the background, making it very suitable for network security analysis.
5. <span>hping3</span> — A Powerful Tool for Port Scanning and Packet Testing
<span>hping3</span> is a highly capable network testing tool that can construct arbitrary packets for port scanning, firewall testing, IP spoofing, and even simulating DoS attacks (for experimental environments only).
Usage Example:
To test if port 80 on a host is open:
hping3 -S -p 80 example.com
If you receive a SYN-ACK response, the port is open.
To simulate a DoS test (dangerous operation, for internal network experiments only):
hping3 -S -p 80 --flood 192.168.1.10
Installation Method
If these commands are not installed by default, you can use:
sudo apt install iftop mtr nmcli dnstop hping3
Conclusion
These 5 commands may not be the most common Linux network tools, but once mastered, they will become your reliable assistants for troubleshooting networks, analyzing traffic, and understanding system behavior. Whether you are a maintenance engineer or a Linux enthusiast, they are worth bookmarking and trying out.