Quantcast
Linux Hacks

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

By July 13, 2018 No Comments
Linux

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:

#curl -o example.zip https://github.com/curl/curl/archive/master.zip

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:

#lynx https://www.google.com

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 me know! mcmanus@automox.com.

About Automox
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.

Joe McManus

Author Joe McManus

Joe is a Senior Cyber Security Researcher at CERT and a Professor at the University of Colorado College of Engineering where he teaches graduate courses in information security and forensics. Recently, Joe was the Director of Security at SolidFire, (acquired by NetApp [NTAP]). He is an avid cyclist, climber and leads the Automox security team.

More posts by Joe McManus

Leave a Reply