Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#linux-networking-tools

Linux Networking Tools Cheatsheet

A quick reference for modern Linux networking commands. Note that iproute2 (ip command) has largely replaced net-tools (ifconfig, route).

Basic Network Configuration (ip)

ip a                      # Show all IP addresses (ip addr show)
ip link                   # Show status of all network interfaces
ip link set eth0 up       # Bring interface eth0 UP
ip link set eth0 down     # Bring interface eth0 DOWN
ip route                  # Show routing table
ip route add default via 192.168.1.1  # Set default gateway

Troubleshooting Connectivity

ping google.com           # Test connectivity via ICMP echo requests
ping -c 4 google.com      # Send exactly 4 pings
traceroute google.com     # Trace the route packets take to a host
mtr google.com            # Combines ping and traceroute (dynamic updates)

DNS and Name Resolution

# dig (Domain Information Groper) - Most detailed
dig google.com            # A record query
dig -t MX google.com      # Query specific record type (MX, TXT, NS, CNAME)
dig @8.8.8.8 google.com   # Query a specific DNS server (Google's 8.8.8.8)
dig +short google.com     # Return only the IP address
 
# host - Simpler output
host google.com
host 8.8.8.8              # Reverse DNS lookup
 
# Check local resolver config
cat /etc/resolv.conf

Ports and Connections

# ss (Socket Statistics) - Replaces netstat
ss -tuln                  # List all listening TCP and UDP ports (numeric)
ss -tulpn                 # Same as above, but show Process ID (requires sudo)
ss -s                     # Show socket usage summary
 
# netstat (Legacy, but still common)
netstat -tuln

Network Analysis & Packet Sniffing

# tcpdump
sudo tcpdump -i eth0            # Capture all traffic on eth0
sudo tcpdump -i eth0 port 80    # Capture only HTTP traffic on eth0
sudo tcpdump host 192.168.1.10  # Capture traffic to/from a specific IP
sudo tcpdump -w capture.pcap    # Save capture to a file (openable in Wireshark)
 
# nmap (Network exploration and security auditing)
nmap 192.168.1.0/24             # Scan an entire subnet for active hosts
nmap -p 1-1000 192.168.1.10     # Scan ports 1 to 1000 on a host
nmap -p 22,80,443 example.com   # Scan specific ports

Downloading Files

wget https://example.com/file.zip    # Download a file
wget -c https://example.com/file.zip # Resume an interrupted download
curl -O https://example.com/file.zip # Download using curl