cURL is a command-line tool that transfers data to and from servers. It supports HTTP, HTTPS, FTP and SFTP protocols, allowing you to download files directly from the terminal without a browser.
You will use cURL to retrieve files, save them with their original names or rename them during download. This works on any hosting environment where you have SSH access.
The basic cURL command downloads a file and displays its contents in your terminal window. This confirms the file is accessible before you save it.
curl followed by the file URL. For example: curl https://www.unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svgThe file contents appear in your terminal. This verifies the URL works correctly before you proceed to save the file.

cURL offers two options for saving files. The uppercase -O flag preserves the original filename, while the lowercase -o flag lets you specify a new name.
-O flag to your command: curl -O https://www.unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svg This saves the file as uwh_vps_hosting_hero.svg in your current directory.
-O.-o flag followed by your chosen filename: curl -o hero_image.svg https://www.unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svg This saves the file as hero_image.svg instead of the original name.
-o.Both methods download the complete file to your current working directory. Check the directory contents with ls to confirm the file saved correctly.
Some URLs redirect to different addresses. The -L flag tells cURL to follow these redirects automatically, which prevents download failures.
-L in your command: curl -o hero_image.svg -L http://unlimitedwebhosting.co.uk/assets/images/vps/uwh_vps_hosting_hero.svg This follows HTTP to HTTPS redirects and downloads from the final destination.Without the -L flag, cURL stops at the redirect and fails to download the file. Always include this flag when working with URLs that might redirect.
cURL works with FTP and SFTP servers. You need to provide authentication credentials using the -u flag when the server requires a login.
curl -u username:password ftp://ftp.yourftpserver.tld/backup.tar.gz Replace username and password with your FTP credentials, and update the server address and filename.ftp:// to sftp:// in the URL: curl -u username:password sftp://ftp.yourftpserver.tld/backup.tar.gz SFTP encrypts the connection for better security.Combine the -u flag with -O or -o to save FTP downloads. For example: curl -u username:password -O ftp://ftp.yourftpserver.tld/backup.tar.gz saves the file with its original name.
You can now download files from the command line using cURL. You retrieved file contents, saved files with original or custom names, handled URL redirects and accessed FTP servers with authentication.
Review our guides on connecting via SSH and managing files on your hosting account for more command-line techniques. Our web hosting plans include full SSH access for command-line file management.
Get scalable resources with our VPS hosting with root access and optional software.
Get VPS HostingPerfect for websites and small businesses unlimited bandwidth with cPanel hosting.
Get cPanel Hosting