Linux Networking Commands
This cheatsheet provides essential Linux networking commands for system administrators and power users. Covering basic configuration, diagnostics, firewall management, network services, file transfers, and advanced operations, it's a comprehensive reference for network troubleshooting and setup.
Linux Networking Commands
Essential commands for network configuration and diagnostics
Commands
Categories
Favorites
Topics
ifconfigDisplay network interfaces and their configuration
ip addrShow IP addresses and network interfaces (modern)
ip linkDisplay and modify network interfaces
iwconfigDisplay and configure wireless network interfaces
ping [host]Test connectivity to a network host
ping -c 4 [host]Ping host 4 times and exit
hostnameShow or set system hostname
netstat -tulnDisplay active internet connections
ss -tulnDisplay socket statistics (modern netstat)
route -nDisplay IP routing table
ip routeShow and manipulate routing table (modern)
traceroute [host]Trace packet route to network host
tracepath [host]Trace path to a network host
dhclient [interface]Obtain IP address via DHCP
ip addr add [ip]/[mask] dev [interface]Set IP address for interface
ip link set [interface] up/downEnable/disable network interface
ip route add default via [gateway]Add default gateway
nmcli device wifi connect [SSID]Connect to WiFi network
nmcli con showList network connections
nmtuiNetwork Manager text user interface
ethtool [interface]Display or change Ethernet card settings
iwlist [interface] scanScan for wireless networks
resolvectl statusShow DNS resolver status (systemd)
iptables -LList all firewall rules
iptables -A INPUT -p tcp --dport 22 -j ACCEPTAllow incoming SSH connections
iptables -A INPUT -j DROPDrop all other incoming connections
ufw statusCheck UFW firewall status
ufw allow 22/tcpAllow SSH port in UFW
ufw enableEnable UFW firewall
firewall-cmd --list-allList all firewalld rules
firewall-cmd --add-port=80/tcpOpen port 80 in firewalld
firewall-cmd --reloadReload firewall rules
nft list rulesetList nftables rules
mtr [host]Network diagnostic tool combining ping and traceroute
dig [domain]DNS lookup utility
nslookup [domain]Query DNS for domain name or IP mapping
host [domain]DNS lookup utility
whois [domain]Query WHOIS records for domain information
nmap -sP 192.168.1.0/24Scan network for active hosts
tcpdump -i [interface]Capture network packets on interface
tcpdump -i [interface] port 80Capture HTTP traffic
iperf -sRun as server for bandwidth testing
iperf -c [server]Test bandwidth to iperf server
nc -vz [host] [port]Check if specific port is open
curl -I [url]Show HTTP headers for a URL
curl -v [url]Verbose HTTP request/response
systemctl status sshdCheck SSH server status
systemctl restart networkingRestart networking service
systemctl status NetworkManagerCheck NetworkManager status
journalctl -u NetworkManagerView NetworkManager logs
service network restartRestart network service (older systems)
netstat -tulpn | grep LISTENShow listening ports with processes
ss -tulpn | grep LISTENShow listening ports with processes (modern)
lsof -i :80Show process using port 80
ps aux | grep sshShow running SSH processes
systemctl restart dhcpdRestart DHCP server
scp [file] [user]@[host]:[path]Securely copy file to remote host
scp [user]@[host]:[file] [path]Securely copy file from remote host
rsync -avz [dir] [user]@[host]:[path]Sync directory to remote host
rsync -avz --delete [dir] [user]@[host]:[path]Sync and delete extraneous files
sftp [user]@[host]Secure FTP connection to remote host
wget [url]Download file from web server
curl -O [url]Download file from web server
curl -o [file] [url]Download file with custom name
nc -l 1234 > file.txtReceive file on port 1234
nc [host] 1234 < file.txtSend file to host on port 1234
ip tunnel add [name] mode gre ...Create GRE tunnel interface
ip link add [name] type bridgeCreate network bridge
brctl showShow bridge information
ip neighShow neighbor table (ARP cache)
ip -s linkShow interface statistics
ss -sShow socket statistics summary
tc qdisc add dev [interface] ...Configure traffic control
ip monitorMonitor netlink messages
ethtool -S [interface]Show interface driver statistics
ipset listList IP sets
modprobe [module]Load network kernel module
ip -br addr | grep UPShow only active interfaces
curl ifconfig.meShow your public IP address
ss -tp | grep sshShow all SSH connections
ip addr | grep -w inet | grep -v 127.0.0.1Show all non-localhost IP addresses
watch -n1 "ip -s link show [interface]"Monitor interface statistics every second
tcpdump -i [interface] -w capture.pcap port 80Capture HTTP traffic to a file
dig +short mx [domain]Show MX records for domain
nmap -sV -p 1-1000 [host]Scan ports 1-1000 with version detection
netstat -an | grep ':80 ' | sortShow and sort all connections on port 80
ip route get [ip] | head -1Show route path to specific IP
arp -a | sort -k3Sort ARP cache by hardware address
Quick Reference
ip addr
ping [host]
dig [domain]
curl ifconfig.me
Categories
- Basic Networking
Essential commands for viewing and configuring network interfaces, testing connectivity, and displaying routing information.
- Network Configuration
Commands for setting up IP addresses, network interfaces, gateways, and wireless connections.
- Firewall Management
Commands for configuring and managing iptables, ufw, firewalld, and other firewall systems.
- Network Diagnostics
Tools for diagnosing network issues, DNS lookup, packet capture, and port scanning.
- Network Services
Commands for managing network services, checking service status, and monitoring active connections.
- Network File Transfers
Commands for securely transferring files between systems over the network.
- Advanced Networking
Advanced commands for managing tunnels, bridges, traffic control, and network statistics.
- Command Combos
Powerful command combinations for specific network administration tasks.
Features
- Modern and legacy command alternatives
- Organized by functional categories
- Clear, concise command descriptions
- Quick search functionality
- Combination commands for complex tasks
- Responsive design for all devices
- Commands for different Linux distributions
- Covers systemd and init.d service management