Otto background

Linux Hack Of The Week #6: Command Line Web Tools

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

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:

 
 

wget

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)... 192.30.253.112, 192.30.253.113
Connecting to github.com (github.com)|192.30.253.112|: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)... 192.30.253.120, 192.30.253.121
Connecting to codeload.github.com (codeload.github.com)|192.30.253.120|: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

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.

Linus photo 2

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 us know through support@automox.com.

About Automox

Facing growing threats and a rapidly expanding attack surface, understaffed and alert-fatigued organizations need more efficient ways to eliminate their exposure to vulnerabilities. Automox is a modern cyber hygiene platform that closes the aperture of attack by more than 80% with just half the effort of traditional solutions.

Cloud-native and globally available, Automox enforces OS & third-party patch management, security configurations, and custom scripting across Windows, Mac, and Linux from a single intuitive console. IT and SecOps can quickly gain control and share visibility of on-prem, remote and virtual endpoints without the need to deploy costly infrastructure.

Experience modern, cloud-native patch management today with a 15-day free trial of Automox and start recapturing more than half the time you're currently spending on managing your attack surface. Automox dramatically reduces corporate risk while raising operational efficiency to deliver best-in-class security outcomes, faster and with fewer resources.