Selected topic
Networking
Prefer practical output? Use related tools below while reading.
curl is a command-line utility in Linux that allows you to transfer data to and from a server using HTTP, HTTPS, FTP, SCP, SFTP, and other protocols. It's an essential tool for web developers, network administrators, and anyone who needs to interact with servers.
curl is:bash
curl [options] url-X: specifies the request method (e.g., GET, POST, PUT, DELETE)-H: adds a header to the request-d: sends data with the request body-o: saves the output to a filebash
curl https://www.google.com
This will display the HTML code of the page in your terminal.
-X and -d options:
bash
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d "username=john&password=secret" http://example.com/login
This will send a POST request with the specified form data to the server.
index.html:
bash
curl https://www.example.com > index.html
This will save the HTML code of the page to a file named index.html in your current directory.
curl to upload a file to an FTP server:
bash
curl -T localfile.txt ftp://username:password@ftp.example.com/upload/
This will upload the file localfile.txt to the specified FTP server. For SFTP, use the -s option instead of -T.These examples demonstrate just a few of the many uses of curl. Its flexibility and power make it an essential tool for anyone working with web servers or networks in Linux.