Use curl to download files from a terminal. You need curl installed and permission to write to the destination directory. Replace the example URLs with the file addresses you want to download.
Save a file
Choose an output filename with -o:
curl -o file.pdf "https://example.com/file.pdf"The file is saved in your current directory. An existing file with the same name can be overwritten, so choose the destination carefully.
Running curl without an output option writes the response to the terminal instead of saving it as a file. Use -o when downloading a PDF or other binary file.
Choose a different filename
The local filename does not need to match the remote filename:
curl -o file.pdf "https://example.com/long-file-name.pdf"Follow redirects
If the download address redirects to another HTTP location, add -L:
curl -L -o file.tar.gz "https://example.com/download/file.tar.gz"This follows supported HTTP redirects, including a 301 redirect. Check that the saved file is the expected download; a server can return an error page or sign-in page instead.
Download using FTP or SFTP
Curl also supports other transfer protocols, depending on how it was built. An FTP download uses an ftp:// address:
curl -o file.tar.gz "ftp://ftp.example.com/file.tar.gz"FTP and SFTP are different protocols. For an SFTP service, use its sftp:// address and the authentication method specified by the server administrator. Check the Protocols line in curl --version to see whether your installation supports it.
If curl is not installed, see how to install cURL on Linux.