TheLoudCloud
Published in

TheLoudCloud

Download a file from github using Linux commands

wget command is a commonly used CLI to download files from the internet. curl is another command used to transfer data to or from a server.

Say, you’ve a LAMP setup in your Linux machine and want to download a php file form Github. Below is a simple php file that displays the details of an AWS EC2 instance.

If you use this command to download the file, and then open it in a browser. It will just be a github HTML page and not the actual php file.

This is because github typically serves up files with an html wrapper around them. This includes the context and operations you can perform on the file.

Commands like wget and curl just download whatever the server sends them.

Open the raw file

In order to get the actual file, you can get a raw file from github instead.

Copy the URL of the raw file and then use the wget or curl command to download the file.

This will download the raw php file and not the HTML wrapped one.

--

--

Moving away from local everything to cloud everything. Discovering what’s safe, easy, cheap, conviniet.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store