Skip to content

Instantly share code, notes, and snippets.

@sepastian
Created June 25, 2026 10:59
Show Gist options
  • Select an option

  • Save sepastian/ecbcd3d897c62bcf37e7b6c62a5ff478 to your computer and use it in GitHub Desktop.

Select an option

Save sepastian/ecbcd3d897c62bcf37e7b6c62a5ff478 to your computer and use it in GitHub Desktop.
Speedtest CLI using Linux tools only, requires SSH server
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Elegant way to test internet speed on the CLI.
# Mostly from https://superuser.com/a/70400/256215
#
# Does not require large files on a server,
# but requires SSH access to a remote machine.
#
# Replace myserver.com with an SSH server where
# $USER has acces, ideally without password,
# i.e. through key exchange.
#
# Using `pv` between `dd` and `ssh` is optional,
# but gives nice progress information.
dd if=/dev/zero bs=50MB count=1 \
| pv --size 50M --timer --eta --rate --bytes \
| ssh myserver.com 'cat > /dev/null'
@sepastian

sepastian commented Jun 25, 2026

Copy link
Copy Markdown
Author

To go fancy, with coloured output etc.:

#!/bin/bash                                                                                                           
set -euo pipefail
IFS=$'\n\t'

SIZE=100M
HOST=myserver.com
TEXT="sending ${SIZE} to ${HOST}"

dd if=/dev/zero bs="${SIZE}" count=1 2>/dev/null \
    | pv --size	"${SIZE}" --bytes --interval 0.2 --name "${TEXT}" \
      --format ' %{timer} %{sgr:green}%{transferred}%{sgr:reset} %{sgr:green,bold}%{rate}%{sgr:reset} %{sgr:gray,dim}%{eta}%{sgr:reset}' \
      --extra-display 'window:speedtest: %t %b %r %e' \
      --stats \
    | ssh "${HOST}" 'cat > /dev/null'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment