Network Commands Cheatsheet

Essential CLI commands for network troubleshooting and administration

Select Your Operating System

Commands are available for Windows, Linux, and macOS

🚀 Quick Command Reference

ping -t google.com Continuous connectivity test
ipconfig /flushdns Clear DNS cache (Windows)
netstat -tuln Show listening ports (Linux)
traceroute -n 8.8.8.8 Trace route without DNS
arp -a Display ARP cache
nslookup google.com 8.8.8.8 DNS lookup using specific server

Network Diagnostic Commands

Essential commands for testing network connectivity and troubleshooting issues

ping

Test connectivity to a host

Windows
ping google.com
Linux
ping google.com
macOS
ping google.com
Common Options:
-t Continuous ping (Windows)
-c Count of packets (Linux/Mac)
-n Number of packets (Windows)
-s Packet size
-i TTL value
traceroute/tracert

Trace route to destination

Windows
tracert google.com
Linux
traceroute google.com
macOS
traceroute google.com
Common Options:
-h Maximum hops
-w Timeout for each reply
-d Do not resolve addresses
nslookup

Query DNS servers

Windows
nslookup google.com
Linux
nslookup google.com
macOS
nslookup google.com
Common Options:
server Specify DNS server
type= Query type (A, MX, TXT, etc.)
debug Enable debug mode
dig

Advanced DNS lookup

Windows
Not native (use nslookup)
Linux
dig google.com
macOS
dig google.com
Common Options:
+short Brief output
@server Specify DNS server
-x Reverse DNS lookup
ANY Query all record types
pathping

Combination of ping and tracert

Windows
pathping google.com
Linux
mtr google.com
macOS
mtr google.com
Common Options:
-n No DNS resolution
-h Maximum hops
-q Number of queries per hop

Network Configuration Commands

Commands for viewing and modifying network configuration

ipconfig/ifconfig

Display network configuration

Windows
ipconfig /all
Linux
ifconfig -a
macOS
ifconfig -a
Common Options:
/all Detailed configuration (Windows)
/release Release DHCP lease (Windows)
/renew Renew DHCP lease (Windows)
/flushdns Clear DNS cache (Windows)
up/down Enable/disable interface (Linux/Mac)
ip

Modern Linux network configuration

Windows
Not available
Linux
ip addr show
macOS
Not native
Common Options:
addr Manage IP addresses
link Manage network interfaces
route Manage routing table
neigh Manage ARP cache
route

Display/modify routing table

Windows
route print
Linux
route -n
macOS
netstat -rn
Common Options:
add Add a route
delete Delete a route
print Display routing table (Windows)
-n Numerical output
arp

Display/modify ARP cache

Windows
arp -a
Linux
arp -a
macOS
arp -a
Common Options:
-a Display all entries
-d Delete an entry
-s Add static entry
-n Numerical addresses

Network Monitoring Commands

Commands for monitoring network connections and traffic

netstat

Display network connections

Windows
netstat -an
Linux
netstat -tuln
macOS
netstat -an
Common Options:
-a All connections and ports
-n Numerical addresses
-t TCP connections
-u UDP connections
-l Listening ports
-p Show process ID
-r Routing table
-s Statistics
ss

Modern socket statistics

Windows
Not available
Linux
ss -tuln
macOS
Not native
Common Options:
-t TCP sockets
-u UDP sockets
-l Listening sockets
-a All sockets
-n Numerical output
-p Show processes
lsof

List open files/connections

Windows
Not native
Linux
lsof -i
macOS
lsof -i
Common Options:
-i Internet connections
-P Numerical ports
-n Numerical hosts
:port Specific port
tcpdump

Packet capture and analysis

Windows
Use Wireshark
Linux
tcpdump -i eth0
macOS
tcpdump -i en0
Common Options:
-i Interface
-n No DNS resolution
-v Verbose output
-w Write to file
port Filter by port
host Filter by host

Wireless Network Commands

Commands for managing wireless connections

netsh wlan

Windows wireless management

Windows
netsh wlan show profiles
Linux
Use iwconfig/nmcli
macOS
Use airport
Common Options:
show profiles List saved networks
show interfaces Show wireless adapters
connect Connect to network
disconnect Disconnect from network
iwconfig

Linux wireless configuration

Windows
Not available
Linux
iwconfig
macOS
Not available
Common Options:
essid Set network name
mode Set operating mode
channel Set channel
power Power management
airport

macOS wireless utility

Windows
Not available
Linux
Not available
macOS
airport -s
Common Options:
-s Scan for networks
-I Current connection info
-z Disconnect from network

Advanced Network Commands

Advanced commands for network administration

nmap

Network discovery and security auditing

Windows
nmap -sn 192.168.1.0/24
Linux
nmap -sn 192.168.1.0/24
macOS
nmap -sn 192.168.1.0/24
Common Options:
-sn Ping scan
-sS SYN scan
-sV Version detection
-O OS detection
-p Port specification
-A Aggressive scan
curl

Transfer data from/to servers

Windows
curl https://example.com
Linux
curl https://example.com
macOS
curl https://example.com
Common Options:
-I Headers only
-X Request method
-d POST data
-H Custom header
-o Output to file
-v Verbose
wget

Download files from web

Windows
wget https://example.com/file
Linux
wget https://example.com/file
macOS
wget https://example.com/file
Common Options:
-O Output filename
-c Continue download
-r Recursive download
-b Background download
hostname

Display or set system hostname

Windows
hostname
Linux
hostname -f
macOS
hostname
Common Options:
-f Fully qualified domain name
-i IP addresses
-I All IP addresses