The problem: You are logged in to a terminal and you need to download a package, what do you do? Of course you can open up Chrome on your laptop, download the file, scp it over… but there is a better way.
The solution: Linux has a number of command line tools for web browsing and in this week’s Linux Tip we’ll go over a few tools to get you browsing the web like NCSA Mosaic never existed. For these examples I used a Raspberry Pi running Raspbian.
cURL is on of the most commonly used command line apps for downloading. To install it run:
|#apt-get install curl|
To download a file you must add -O or -o filename to prevent it from just printing to stdout.
# curl -O https://github.com/curl/curl/archive/master.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 114 0 114 0 0 211 0 –:–:– –:–:– –:–:– 211
The above example saves a file called master.zip, using the -o option you can provide a filename:
|#curl -o example.zip https://github.com/curl/curl/archive/master.zip|
wget is similar to cURL but I find it easier to use, by default it saves the file to the name of the file in the url. To install run :
|#apt-get install wget|
To download just run wget url:
# wget https://github.com/curl/curl/archive/master.zip
–2018-07-12 03:31:30– https://github.com/curl/curl/archive/master.zip
Resolving github.com (github.com)… 18.104.22.168, 22.214.171.124
Connecting to github.com (github.com)|126.96.36.199|:443… connected.
HTTP request sent, awaiting response… 302 Found
Location: https://codeload.github.com/curl/curl/zip/master [following]
–2018-07-12 03:31:31– https://codeload.github.com/curl/curl/zip/master
Resolving codeload.github.com (codeload.github.com)… 188.8.131.52, 184.108.40.206
Connecting to codeload.github.com (codeload.github.com)|220.127.116.11|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 4687035 (4.5M) [application/zip]
Saving to: ‘master.zip’
master.zip 100%[=====================>] 4.47M 459KB/s in 8.2s
2018-07-12 03:31:39 (561 KB/s) – ‘master.zip’ saved [4687035/4687035]
Lynx has been around for a long time, it is a full-on text-based web browser.
|#apt-get install lynx|
To browse a site run lynx url:
Which then opens a text-based browser which you can use to browse the website from your SSH terminal.
And wow you can now browse the web in a command line way.
These are just a few of the tools you can use to access web resources from the command line. Hopefully one of these can save you in a pinch. As always if you have any questions let me know! email@example.com.
Automox is a cloud-based patch management and endpoint protection platform that provides the foundation for a strong security framework by automating the fundamentals of security hygiene to reduce a company’s attack surface by over 80 percent. A powerful set of user-defined controls enables IT managers to filter and report on the vulnerability status of their infrastructure and intuitively manage cross-platform OS patching, third party patching, software deployment, and configuration management. To sign up for a free, 15-day trial of Automox’s cloud-based, automated patch management solution, visit www.automox.com/signup.