Linux tricks, one-liners & shell magic

#!/bin/vpp.dk

Community Linux tricks, one-liners & shell scripts — searchable & formatted.

Category: networking — 5 trick(s)

+ Add a New Trick

Watch live bandwidth usage broken down by network interface using nload or ifstat.
bash
$ # Using nload (apt install nload): nload eth0 # Without extra tools — poll /proc/net/dev: watch -n 1 'cat /proc/net/dev | column -t'
Delete this trick? This cannot be undone.
Serve the current directory over HTTP for quick file sharing on the LAN — requires only Python 3.
bash
$ python3 -m http.server 8080 # On a specific interface: python3 -m http.server 8080 --bind 0.0.0.0 # Then access from another machine: curl http://<your-ip>:8080/
Delete this trick? This cannot be undone.
Securely transfer files between machines using scp. Works in both directions — local to remote and remote to local.
bash
$ # Local -> Remote scp localfile.txt user@host:/remote/path/ # Remote -> Local scp user@host:/remote/file.txt ./ # Recursive directory copy: scp -r ./mydir user@host:/opt/
Delete this trick? This cannot be undone.
Access a service running on a remote server as if it were local. Useful for databases, dev servers, etc.
bash
$ # Forward remote port 5432 to local port 5432: ssh -L 5432:localhost:5432 user@remote-host # Persistent background tunnel (no shell): ssh -fNL 8080:localhost:80 user@remote-host
Delete this trick? This cannot be undone.
List all listening TCP/UDP ports and the process that owns them.
bash
$ # All listening sockets + process names: ss -tulnp # Or with netstat (older systems): netstat -tulnp # Check if a specific port is open: ss -tulnp | grep ':443'
Delete this trick? This cannot be undone.