Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»5 Curl Commands to download Files

    5 Curl Commands to download Files

    By RahulAugust 15, 20222 Mins Read

    Curl command file utility supports for downloading and uploading files. Curl is useful for many works with system administration, web development for calling web services, etc. In this tutorial, we are providing 5 frequently used curl commands to download files from remote servers.

    Advertisement

    1. Simple curl command to download file

    To download a file using curl use the following syntax. -O is used for saving files on the local system with the same name on the remote system.

    curl -O http://example.com/download/myfile.zip 
    

    2. Curl download file and save with different name

    You can also save the downloaded file with a different name on the local machine. Use -o followed by the new file name to download and save files with a different name.

    curl -o localname.zip http://example.com/download/myfile.zip 
    

    3. Curl to Download Multiple Files

    Curl also provides an option to download multiple files simultaneously. To download multiple files at once using the following syntax. All files will be saved with original file names.

    curl -O http://example.com/myfile.zip -O http://example.com/myfile2.zip 
    

    4. Use Login Credential with Curl Download

    Some of the remote resources required authentication to download any file. Curl also allows you to provide authentication details to authorize requests. You can pass login credentials using -u option for HTTP for FTP requests, like:

    curl -u user:password -O http://example.com/myfile.zip 
    curl -u ftpuser:ftppassword -O ftp://ftp.example.com/myfile.zip 
    

    5. Curl download file via proxy

    If the server file is only available through a proxy server, or you want to use a proxy for downloading files, Use -x followed by a proxy address and port to download the file via a proxy server.

    curl -x "my.proxy.com:3128" -O http://example.net/myfile.zip 
    

    Conclusion

    Curl is a useful utility to create GET, POST, HEADER, and many other requests to remote servers. Even it is helpful for downloading remote files quickly like wget. This tutorial 5 examples of the curl commands for downloading files from a remote server.

    curl download
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    cp Command in Linux (Copy Files Like a Pro)

    dd Command in Linux (Syntax, Options and Use Cases)

    Top 10 JQ Commands Every Linux Developer Should Know

    View 5 Comments

    5 Comments

    1. krishna chaitanya on June 1, 2021 6:03 pm

      how to download file to different directory using curl.

      Reply
      • Rahul on June 2, 2021 3:53 am

        Use -o with curl command to save file in other directory. Like:

        curl http://example.com/myfile.zip -o /tmp/myfile.zip 
        
        Reply
    2. Mubbeena on June 28, 2018 7:59 pm

      I don’t know who you are but THANK YOU!!!!!!!!!!!!!!!

      Reply
    3. amit on July 12, 2017 8:18 am

      Hi ,
      /usr/bin/curl”,”-k”,”-u”,userName+”:”+password,”\””+hostIP+”\””,”-o” ,csvDownloadPath+”ggggg.csv”

      I am using this command , where i am doing wrong, we are not getting any error in logs, running this command in java ,on linux server.

      Reply
      • amit on July 12, 2017 8:23 am

        try{
        ProcessBuilder pb = new ProcessBuilder(“/usr/bin/curl”,”-k”,”-u”,userName+”:”+password,”\””+hostIP+”\””,”-o” ,csvDownloadPath+”ggggg.csv”);
        Process p = pb.start();
        InputStream is = p.getInputStream();
        System.out.println(“command running “);
        }
        catch(Exception e){
        e.printStackTrace();
        System.out.println(“command running through “);

        Actually running this…
        plz guide me , Thanks In advance

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.