How to install curl on Alpine Linux

Curl is URL retrieval (download/upload) command-line utility and library. It is free software for Alpine Linux. This page explains how to search and install curl on Alpine Linux using the apk command.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Alpine Linux
Est. reading time 2 minutes

Installing curl on Alpine

  1. Open the terminal application. For remote server use the ssh command for login purposes. For instance:
    ssh user@alpine-ec2-server
  2. Update apk database indexes from all configured packages. Run:
    apk update
  3. Apply all pending security updates on Alpine Linux, type:
    apk upgrade
  4. Search for curl packages under Alpine:
    apk search curl
    Searching curl package on Alpine Linux
  5. Let us see information known about the listed packages called curl:
    apk -a info curl
    apk -v info curl
    Alpine Linux install curl by searching the package
  6. Finally install curl package in Alpine Linux:
    apk add curl
    Installing curl on Alpine Linux using apk command

Finding out curl version

We must verify curl installation and other featured. Hence, type the following command to see the installed version:
curl --version

curl 7.74.0 (x86_64-alpine-linux-musl) libcurl/7.74.0 OpenSSL/1.1.1j zlib/1.2.11 brotli/1.0.9 nghttp2/1.42.0
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

The above command successfully verified that curl was installed on my Alpine Linux laptop.

Installing curl documentation and man pages

Use the apk command:
apk add curl-doc

(1/1) Installing curl-doc (7.74.0-r1)
Executing mandoc-apropos-1.14.5-r5.trigger
OK: 1109 MiB in 249 packages

Now use the man command:
man curl
curl man page under Alpine Linux
See how to install man pages on Alpine Linux and colored man pages with less command for more info.

How to use curl to download files

Let us grab a file named book.pdf:
curl https://your-domain/book.pdf
Get files using ftp or sftp protocol:
curl ftp://ftp-your-domain-name/examples.tar.gz
You can set the output file name while downloading file with the curl, execute:
curl -o sweet.pdf https://your-awesome-domain-name/bad-long-long-file-name.pdf
Make sure we do a 301-redirected file while downloading files with curl, run:
curl -L -o file.tgz http://www.cyberciti.biz/very-long.file.name.tgz

We can see the HTTP headers for any domain:
curl -I https://bash.cyberciti.biz/

HTTP/2 200 
date: Sat, 20 Mar 2021 09:07:00 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=da48bf4f1f36af7e4226658b8b3b1b0531616231220; expires=Mon, 19-Apr-21 09:07:00 GMT; path=/; domain=.cyberciti.biz; HttpOnly; SameSite=Lax; Secure
vary: Accept-Encoding
front-end-https: on
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-whome: l-ncbz01
referrer-policy: strict-origin-when-cross-origin
feature-policy: accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'
cf-cache-status: DYNAMIC
cf-request-id: 08f07c5da7000017b359919000000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
strict-transport-security: max-age=15552000
server: cloudflare
cf-ray: 632dc9a909ef17b3-SIN
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400

Summing up

We explained how to install the curl command on Alpine Linux for downloading files, troubleshooting remote server usage, and more. See curl man page or documentation:
man curl


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Jose Mar 20, 2021 @ 12:29

    In step 5 you have a typo. Shouldn’t:
    curl -v info curl
    be
    apt curl -v info curl
    ? You havent installed curl yet

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum