Network
Networking commands, SSH, DNS, and troubleshooting reference.
Network Developer Guide
Networking commands help you connect to remote systems, move files, inspect interfaces, troubleshoot DNS, monitor traffic, and manage firewall rules from the command line.
Remote Access
SSH Connections
Use SSH to log in to remote servers, run commands, and create encrypted tunnels:
ssh username@remote_host # Log in to a remote server
ssh -p port_number username@remote_host # Connect on a specific port
ssh username@remote_host command_to_run # Run a command remotely
ssh -i /path/to/private_key username@remote_host # Authenticate with a private key
ssh-copy-id username@remote_host # Copy public key for passwordless SSHSSH Port Forwarding
Forward ports when you need to reach services through an SSH connection:
ssh -L local_port:destination_host:destination_port username@remote_host # Local port forwarding
ssh -R remote_port:destination_host:destination_port username@remote_host # Reverse port forwardingFile Transfer
Copying Files with SCP
Use scp for simple encrypted file copies over SSH:
scp /path/to/local_file username@remote_host:/path/to/remote_dir # Local file to remote
scp username@remote_host:/path/to/remote_file /path/to/local_dir # Remote file to local
scp -r /path/to/local_dir username@remote_host:/path/to/remote_dir # Copy directory recursivelySyncing Files with Rsync
Use rsync when you need efficient incremental transfers:
rsync -avz /path/to/local_dir username@remote_host:/path/to/remote_dir # Sync local to remote
rsync -avz username@remote_host:/path/to/remote_dir /path/to/local_dir # Sync remote to local
rsync -avz --delete /path/to/source_dir username@remote_host:/path/to/destination_dir # Delete destination files missing from sourceConnectivity Checks
Basic Reachability
Start with simple reachability checks before moving into deeper diagnostics:
ping remote_host # Check whether a host responds
traceroute remote_host # Trace the route packets take to a host
nc -zv remote_host port_number # Test whether a specific TCP port is reachablePort and Service Discovery
Inspect listening services and open ports on local or remote systems:
nmap remote_host # Scan open ports on a remote host
netstat -an # Show active connections and listening ports
ss -tuln # Show TCP/UDP listening socketsInterface and Routing
Network Interfaces
Display interface names, addresses, and link information:
ip addr # Show interfaces and IP addresses
ifconfig # Legacy interface display commandRouting and Hostnames
Review routing decisions and update host identity:
ip route # View routing table
ip route add destination_network via gateway_ip dev interface # Add a static route
sudo hostnamectl set-hostname new_hostname # Change system hostnameDNS Troubleshooting
DNS Queries
Use DNS tools to verify records and troubleshoot name resolution:
nslookup domain_name # Query DNS for a domain
dig domain_name # Perform a detailed DNS query
dig domain_name A # Query A records
dig domain_name MX # Query mail exchange records
dig @dns_server domain_name # Query a specific DNS serverMonitoring and Diagnostics
Traffic Monitoring
Capture packets or watch bandwidth usage on an interface:
tcpdump -i interface # Monitor traffic on an interface
tcpdump -i interface port 443 # Capture traffic for a specific port
iftop -i interface # Show bandwidth usage by connectionFile and Process Diagnostics
Inspect files opened by a process or stop processes that are causing trouble:
lsof -p process_id # View open files used by a process
pkill process_name # Kill a process by name
kill -9 process_id # Force kill a process by PIDFirewall Management
UFW Commands
Use UFW to manage common Linux firewall rules:
sudo ufw enable # Enable UFW
sudo ufw status # Check firewall status
sudo ufw allow port_number # Allow traffic on a specific port
sudo ufw allow 22/tcp # Allow SSH over TCP
sudo ufw deny port_number # Deny traffic on a specific portWeb and Speed Tests
Downloads and Internet Checks
Use these commands to fetch files and check external connectivity:
speedtest-cli # Check internet speed
wget file_url # Download a file
curl -O file_url # Download a file and keep the remote filename
curl -I https://example.com # Fetch HTTP response headers