Learn the command to install the CURL tool on Alpine Linux to transfer or download files using various protocols.
cURL is a program that enables files to be transferred from or to a server without user interaction. In addition to HTTP, the program supports a variety of other network protocols such as FTP, FTPS, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. It is controlled via command-line parameters that are specified when the program is called.
cURL uses the libcurl library for all functions relating to data transfer. It is often used for working with REST -ful services, e.g. for developing or debugging such services.
Alpine Linux is not much popular among the standard Linux users but it has been used by advanced users because of its lightweight, high performance, and security.
Steps to install cURL on Alpine Linux using command line
The steps given below will work on all the latest and old Alpine Linux versions. However, here we are using Version 3.14.
1. Refresh repositories
Well, it is a good idea to run the system update command once on Linux to refresh the repositories cache before installing any application.
apk update
2. Install Curl on Alpine Linux
The package to install cURL on Alpine Linux is already there on Alpine Linux’s default main repository, hence just need to use the APK package manager to add it to the system.
apk add curl
3. Usage
From a terminal you can call cURL as follows:
curl Optionen... URL
Options of cURL
Log options | |
-v , --verbose |
Provides extensive information on client-server communication. |
--trace DATEI , --trace-ascii DATEI |
Provides even more detailed information than --verbose and writes it to the specified file. |
Upload options | |
-T DATEI URL , --upload-file DATEI URL |
Transfers the file to the specified destination. |
Download options, work with HTTP | |
-C , --continue-at OFFSET |
Continuation or resumption of a previous file transfer at the specified point. -C - causes CURL to automatically find out where and how the transfer can be resumed based on the given output/input files. |
-L , --location |
Follows redirects (only HTTP / HTTPS) |
-o DATEI , --output DATEI |
Writes the contents of the downloaded file to the specified FILE instead of standard output |
-r BEREICH , --range BEREICH |
Gets only the bytes within the specified RANGE. If the server does not support this, the entire file will be downloaded. |
-O , --remote-name |
Writes the content of the downloaded file to a file of the same name. |
-X COMMAND URL , --request COMMAND URL |
Executes the specified HTTP command on the specified URL. |
-x PROTOCOL://HOST:PORT , --proxy PROTOCOL://HOST:PORT |
Uses the specified proxy. The protocol and port are optional. |
-U USER:PASSWORD , --proxy-user USER:PASSWORD |
Uses the specified proxy user. The password is optional. |
-u USER:PASSWORD |
passes access data |
Examples
Use cURL to Download files
curl -o file-url
Example
curl -o https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-standard-3.14.2-x86_64.iso
In case the downloading of the file has been interrupted or canceled, it could be continued or resumed with the help of option -C.
Example:
curl -C - -o https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-standard-3.14.2-x86_64.iso
With the option -C –, the transmission will automatically be resumed at the point where it was interrupted.