Network Commands
hostname — Machine name
hostname # Show hostname
hostname -I # Show all IP addresses
hostname -f # Fully qualified domain name
ip — Modern network info
ip addr # Show all network interfaces and IPs
ip addr show eth0 # Specific interface
ip route # Show routing table
ip link # Link layer info
ifconfig (older)
ifconfig # All interfaces
ifconfig eth0 # Specific interface
ping — Test connectivity
ping google.com # Ping until Ctrl+C
ping -c 4 google.com # Ping 4 times only
ping -i 2 host # Ping every 2 seconds
ss / netstat — Open ports
ss -tlnp # TCP listening ports with process
ss -tulnp # TCP+UDP listening
netstat -tlnp # Older equivalent
/etc/hosts — Local DNS
cat /etc/hosts
Add entries to resolve hostnames locally:
192.168.1.100 myserver.local
nslookup / dig — DNS lookup
nslookup google.com
dig google.com
dig +short google.com A # Just the IP