guest@linuxthings:~/guides$ man networking
Networking
Diagnostics
ping google.com # Check connectivity (Ctrl+C to stop)
ping -c 4 google.com # Send just 4 pings
traceroute google.com # Trace path to host
mtr google.com # Live, continuously updated traceroute
host google.com # DNS lookup
host -t MX gmail.com # Look up a specific record type
dig example.com # Detailed DNS lookup
dig +short example.com A # Just the answer
whois example.com # Domain registration detailsA host that does not answer ping may simply be blocking ICMP behind a firewall, so try connecting to a real service before concluding it is down.
Interfaces and Routes (ip)
ip addr show # Show IP addresses
ip -br addr # One-line summary per interface
ip addr show eth0 # Details for one interface
ip link # Interface state and MAC addresses
ip route # Routing table, including the default gateway
hostname -I # All of this host's IP addresses
cat /etc/resolv.conf # DNS servers in use
resolvectl status # DNS settings on systemd-resolved systemsifconfig and route still appear in older guides but are deprecated on modern distributions in favour of ip.
Ports and Connections (ss)
ss -tulpn # Listening TCP/UDP ports and the owning process
ss -t state established # Current TCP connections
ss -tp | grep sshd # Connections belonging to one program
sudo lsof -i :443 # Which process is using port 443
netstat -tulpn # Older equivalent of ss (net-tools package)
nc -zv host 22 # Test whether a TCP port is openRun ss -p or lsof with sudo to see processes owned by other users.
NetworkManager (nmcli)
nmcli device status # Interfaces and their connection state
nmcli connection show # Saved connections
nmcli dev wifi list # Nearby Wi-Fi networks
nmcli dev wifi connect "SSID" --ask # Join a Wi-Fi network
nmcli connection up "name" # Activate a saved connectionFirewall
sudo ufw status verbose # Ubuntu's simple firewall
sudo ufw allow 22/tcp # Allow SSH
sudo ufw allow from 192.168.1.0/24 to any port 22
sudo ufw enable # Turn it on
sudo firewall-cmd --list-all # firewalld (Fedora, RHEL)
sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reloadAllow SSH before enabling a firewall on a remote machine, or you will lock yourself out.
Remote Access (SSH)
ssh user@host # Secure remote login
ssh -p 2222 user@host # SSH on custom port
ssh user@host df -h # Run one command remotely
ssh -v user@host # Verbose output for debugging a failed login
scp file user@host:path # Secure file copy to remote
scp user@host:file . # Secure file copy from remote
scp -r dir user@host: # Copy a directory recursively
sftp user@host # Interactive file transfer (get, put, ls, quit)SSH Keys
Key-based logins are more secure than passwords and save typing.
ssh-keygen -t ed25519 # Create a key pair in ~/.ssh
ssh-copy-id user@host # Install your public key on the server
ssh user@host # Log in with the keyIf key login fails, check permissions: ~/.ssh should be 700, private keys and ~/.ssh/authorized_keys should be 600. Save frequent connections in ~/.ssh/config:
Host web
HostName 203.0.113.10
User deploy
Port 2222
# Now just run: ssh webTunnels
ssh -L 8080:localhost:80 user@host # Local port 8080 reaches port 80 on host
ssh -D 1080 user@host # SOCKS proxy through hostData Transfer
wget url # Download file
wget -c url # Resume an interrupted download
curl -O url # Download file
curl -L -o name.zip url # Follow redirects and choose the filename
curl -I url # Fetch headers only
curl -s https://api.example.com/items | less # Fetch an API response quietlyNever pipe a downloaded script straight into bash. Save it, read it, then decide whether to run it.