Linux
linuxlinuxGuideIntermediate
Linux Networking Commands Reference
Inspect network interfaces with ip, check listening ports with ss, test connectivity with ping and curl, and configure firewalls with ufw.
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linux
#linux#networking#ip#ss#curl#ping
1. Network Interface & IP Inspection (ip)
The modern ip command replaces deprecated legacy tools like ifconfig:
# Show all network interfaces and assigned IPv4/IPv6 addresses
ip a
# or
ip addr show
# Show default gateway and routing table
ip route show2. Checking Listening Ports & Sockets (ss)
The ss (Socket Statistics) utility is the modern, high-performance replacement for netstat:
# List all listening TCP/UDP ports with process names and PIDs
sudo ss -tulpn
# Filter for a specific listening port (e.g. 3000 or 5432)
sudo ss -tulpn | grep :3000Flags Breakdown:
-t: TCP sockets.-u: UDP sockets.-l: Listening sockets only.-p: Show process name and PID.-n: Numeric port numbers (shows5432instead ofpostgresql).
3. Connectivity & DNS Testing
# Test ICMP echo network latency
ping -c 4 1.1.1.1
# HTTP request inspection
curl -Iv https://example.com
# Test raw TCP port connectivity using netcat
nc -zv 192.168.1.50 5432
# Trace network routing hops
traceroute 8.8.8.8
# DNS resolution query
dig api.example.com +short4. Uncomplicated Firewall (ufw) on Ubuntu
# Allow SSH, HTTP, and HTTPS
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Enable firewall
sudo ufw enable
# Check firewall rules
sudo ufw status verboseLinux Memory Management & Swap
Monitor system RAM and Swap with free, understand Linux buffer/cache allocation, vmstat metrics, and prevent Out-Of-Memory (OOM) kills.
Linux Logs & journalctl Troubleshooting
Inspect Linux system logs, query systemd services with journalctl, filter by time and priority, and manage logrotate.