curl command in Linux is an excellent utility that’s used to modify data from or to a neighborhood server, leveraging a big selection of protocols like HTTP, HTTPS, FTP, and SFTP.
In more effective words, it’s a tool this is serving to you turn data over the internet in an instant from your command line. For instance, you’ll use
curl to acquire a file from a URL, or upload a file to a server.
This command-line instrument is not just about transferring data. You’ll moreover use
curl to make HTTP requests, identical to GET and POST, from your terminal. This is extremely useful when checking out or interacting with web services and products and merchandise and APIs. With
curl, you’ll even check out the content material materials of a web internet web page without if truth be told opening it in a browser, as it should smartly fetch and display the raw data.
Listed below are some other ways to use the
The most straightforward way to use
curl is to type
curl followed by the use of the URL of the internet web page you wish to have to get admission to.
While you run the command
curl http://example.com throughout the terminal, it sends a
GET request to the server positioned at
http://example.com. The output that you just see on the terminal is the server’s response to this
GET request, maximum ceaselessly the HTML content material materials of the webpage.
1. Save Output to a File
By means of default,
curl outputs the provision of the internet web page that you just requested. If you want to save this output to a file, you’ll use the
curl -o output.html http://example.com
-o selection allows you to specify a filename, while
-O will use the filename from the URL.
2. Practice Redirects
If the URL you’ve requested redirects to each and every different internet web page,
curl won’t observe the redirect till you include the
curl -L http://example.com
3. Send POST Requests
curl to send POST requests. This is endlessly used when submitting bureaucracy.
curl -d "param1=value1¶m2=value2" -X POST http://example.com/type
-d selection tells
curl that you just’re going to send POST data, and the
-X selection specifies the request method to use.
4. Send GET Requests with Parameters
You’ll send a GET request with parameters by the use of appending them to the URL.
5. Send Headers
You’ll add headers to your request with the
curl -H "Accept: tool/json" http://example.com/api
curl to send cookies with the
-b selection, and to store cookies with the
curl -b "establish=price" -c cookies.txt http://example.com
7. Upload Knowledge
curl so as to add data to a server with the
-F selection. This sends a POST request and devices the
Content material material-Kind to
curl -F "file=@path/to/local/file" http://example.com/upload
8. Download Knowledge
curl to acquire data using FTP, SFTP, HTTP, and numerous other protocols.
curl -O ftp://example.com/pub/file.zip
If you wish to authenticate, you’ll use the
-u selection followed by the use of the username and password separated by the use of a
curl -u username:password http://example.com
Additional Linux directions:
|File System Operations||
|Search and Text Processing||
|System Wisdom and Keep watch over||
|Individual and Session Keep watch over||