40 Powerful Linux Networking Commands You Must Know.

Linux networking commands are foundational for effective network management and troubleshooting, particularly in roles like DevOps and Site Reliability Engineering (SRE). This guide introduces 50 essential Linux commands, each designed to make network troubleshooting, monitoring, and configuration straightforward. Mastery of these commands can help you swiftly diagnose network issues, monitor bandwidth, and configure complex network setups with confidence.
Basic Network Information 🌐
These commands help you quickly access network configuration details.
1. ifconfig
Displays network interface information.
Example:
ifconfig
2. ip
Shows or manipulates IP addresses, routing, and network devices.
Example:
ip address show
3. route
Displays or modifies the IP routing table, useful for managing traffic routes.
Example:
route -n
4. hostname
Shows or sets the system’s hostname.
Example:
hostname
5. hostnamectl
Controls hostname settings and provides status info.
Example:
hostnamectl status
Testing Network Connectivity 🔍
Use these commands to verify connectivity to other hosts and test network routes.
6. ping
Sends packets to a host to check connectivity and response times.
Example:
ping google.com
7. traceroute
Traces the path packets take to a host, helping identify delays or connectivity issues.
Example:
traceroute google.com
8. mtr
Combines
ping
andtraceroute
functionalities, offering real-time network diagnostics.Example:
mtr google.com
9. fping
Pings multiple hosts quickly, useful for network discovery.
Example:
fping -a -g 192.168.1.1 192.168.1.254
DNS and Name Resolution 🌍
These commands assist with domain name resolution and troubleshooting DNS issues.
10. dig
Performs DNS lookups, showing detailed information about domain names.
Example:
dig google.com
11. nslookup
Interactively queries Internet name servers.
Example:
nslookup google.com
12. host
Another utility for DNS lookups.
Example:
host google.com
13. resolvconf
Manages DNS information and updates settings.
Example:
resolvconf -u
Monitoring Network Connections 📈
These commands provide insights into network traffic and open connections on your system.
14. netstat
Displays network connections, routing tables, and interface statistics.
Example:
netstat -an
15. ss
Displays socket statistics, a faster alternative to
netstat
.Example:
ss -tulpn
16. lsof
Lists open files, showing which files are being accessed over the network.
Example:
lsof -i :80
17. iftop
Monitors bandwidth usage in real-time, visualizing data usage per interface.
Example:
iftop
18. nload
Visualizes incoming and outgoing network traffic.
Example:
nload
Managing Network Interfaces and Routes 🔧
Use these commands to configure network interfaces, routing tables, and traffic flow.
19. iptables
Tool for packet filtering and NAT configuration, used for firewall setup.
Example:
iptables -L
20. iptraf
An interactive network monitor, perfect for live traffic analysis.
Example:
iptraf
21. ethtool
Displays or modifies settings on Ethernet devices.
Example:
ethtool eth0
22. arp
Shows or modifies the Address Resolution Protocol (ARP) cache.
Example:
arp -a
23. iwconfig
Configures wireless network interfaces.
Example:
iwconfig
24. nmcli
A command-line client for NetworkManager, used to manage connections.
Example:
nmcli connection show
25. nmtui
Text-based interface for NetworkManager, making it easy to manage network settings.
Example:
nmtui
Data Transfer and Remote Access 🔒
These tools help transfer data and manage files across remote systems securely.
26. scp
Securely copies files between hosts.
Example:
scp file.txt user@remote:/path
27. wget
Downloads files from the internet non-interactively.
Example:
wget
http://example.com/file.zip
28. curl
Transfers data to and from servers, great for testing APIs.
Example:
curl
http://example.com/api
29. telnet
Connects to other systems using the TELNET protocol.
Example:
telnet google.com 80
30. nc (netcat)
Utility for creating arbitrary TCP and UDP connections.
Example:
nc -l 8080
31. ssh-keygen
Generates and manages SSH authentication keys.
Example:
ssh-keygen -t rsa
Security and Diagnostics 🔐
Monitor network security, troubleshoot issues, and gather diagnostic information.
32. tcpdump
Captures network packets for analysis.
Example:
tcpdump -i eth0
33. nmap
Scans networks for open ports and vulnerabilities.
Example:
nmap -sP 192.168.1.0/24
34. iperf
Measures TCP and UDP bandwidth performance, useful for network performance testing.
Example:
iperf -c server_ip
35. sshd
Manages the SSH daemon for secure remote access.
Example:
service sshd restart
Additional Commands for Network Management ️
These commands cover specific scenarios, from adding routes to checking system stats.
36. route add
Adds a new route to the routing table.
Example:
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
37. route del
Deletes a route from the routing table.
Example:
route del -net 192.168.2.0 netmask 255.255.255.0
38. ss -s
Shows summary of socket statistics.
Example:
ss -s
These 40 commands provide a solid foundation for effective Linux network management, empowering you to quickly identify and resolve network issues, monitor performance, and configure network settings across multiple systems. By integrating these tools into your troubleshooting process, you’ll be better equipped to maintain reliable and secure network infrastructure.
💬 If you have any suggestions or questions, please leave a comment below! 👏 If you found this article helpful, feel free to give it a clap and share it with your friends.
Feel free to connect, and let’s continue the conversation!😊
YouTube: Techwithpatil
LinkedIn: Tech with Patil
Instagram: techwithpatil
Thank you! 🙏
Written by techwithpatil150 Followers·259 Following
DevOps | SRE | Carrers | Cloud | AI | Software Automation https://techwithpatil.com
Last updated