Run curl -O followed by the file's URL to save it under its original name, or curl -o with a new filename before the URL to rename it. Adding -L makes cURL follow redirects, which otherwise stop the download. Plain curl with a URL prints the file in the terminal rather than saving it. For a File Transfer Protocol (FTP) or SFTP server, add -u with your username and password.
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 https://www.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.
Did this guide solve your problem?
Our UK support team answers tickets and live chat every day. Send us the guide you were following and where it stopped working.
Related guides
cPanel hosting with the tools these guides use, backed by UK support.
Get cPanel HostingProtect your visitors with SSL certificates – from budget DV to premium EV certificates.
Get SSL Certificate