How to Run Speed Test from the Command Line to Check Internet Connection Speed
The excellent curl and wget tools provide for a simple way to test the speed of an internet connection directly from the command line. Curl is bundled with most unix variations, but Mac users who want to use the wget trick will first need to grab wget for OS X in order for this to work, wget is a simple terminal utility used to download files from the web and ftp and it’s handy to have around for a variety of uses making it worthwhile to have anyway. Curl should be preinstalled on every unix flavor that is even vaguely modern, including all versions of Mac OS X and linux.
Test Internet Connection Speed from the Command Line
This is a fairly simple trick to check download speeds using the official SpeedTest servers, making it a quick and effect means to check an active internet connection. There are two ways to use this, one utilizing curl, the other uses wget.
Run SpeedTest with curl from the Command Line to Determine Internet Connection Download Speeds
The first trick is to use curl, which is able to download remote files from just about anywhere, retrieve headers, and perform tons of other nifty actions. Curl is bundled with every version of Unix and OS X ever made which makes this a nearly universal command to test download speeds on just about any unix-based computer:
curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
The download speed will show as well as elapsed time to complete the download. Here is what this looks like running in a terminal:
The “Test10.zip” file is being sent to /dev/null so don’t worry about taking up disk space with a useless test file.
If you think you’ll use the curl trick often, consider adding it to your profile as an alias:
alias speedtest='curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
Thanks to one of our commenters for this great curl trick.
You’ll probably notice the command itself is quite similar to the wget command string to perform a similar action, so it’s really a matter of preference.
Testing Connection Speed from the Command Line with wget
If you’re already familiar with the command line you know what to do, but others can install wget, then launch Terminal (found in /Applications/Utilities/) and paste the following command string into the terminal:
wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
Look to the righthand side of wget as it runs and you’ll see the connection speed (1.36m/s in the screen shot example). Because wget is pointing the downloaded file at /dev/null it won’t actually take up any hard drive space, so there is no concern about running this command repeatedly.
This uses the same SpeedTest servers that are available to mobile users through the Speed Test app, it can make for a decent way to directly compare connection speeds on a broadband connection vs cellular, without having to access the SpeedTest Flash-based web apps, and without having to compile any additional command line software.
Plan on using this trick often? Consider adding a simple alias to .bash_profile:
alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
Using an alias is obviously shorter and easier to remember, making it a bit more useful for scripts, automation, remote testing, and just for those of us who like to poke around in the Terminal.
This trick comes to us from @climagic on Twitter, be sure to follow @osxdaily there too if you haven’t done so yet.
Is there also a way to test *upload* speed (like speedtest.net does)?
Seems less obvious to me as one would need a server to upload something to, but I’d love to be corrected.
Add “> textfile.txt” to the command. Strip the quotes ;-).
or Add Desktop/textfile.txt
yeah so that doesn’t work with the curl version. Am I missing something? It creates a blank outfile and still shows on the screen
Any suggestions on how I might log the output to a text file?
Do I have to use the speedtest URL to check the speed or is it the actual wget -o /dev/null command that checks the speed?
Nvm disregard above question.
You can also try http://dl.getipaddr.net
They use curl (which is a well known command line utility) to run a speed test.
The code is published on GitHub as well. In short,
wget https://raw.github.com/blackdotsh/curl-speedtest/master/speedtest.sh && chmod u+x speedtest.sh && bash speedtest.sh
For me it gives:
-bash: wget: command not found
Why?
Because you don’t have wget, you should read the article, the second sentence of the article says “Mac users will first need to grab wget for OS X in order for this to work,”
https://osxdaily.com/2013/07/31/speed-test-command-line/
https://osxdaily.com/2012/05/22/install-wget-mac-os-x/
You don’t need to install any extra binaries for this to work, you can use the builtin curl with the lowercase ‘o’ to mimic the command.
curl -o /dev/null
Hey now that’s a cool trick,
curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
Worked instantly, thanks