"cURL" - Client for URL

This section provides a tutorial example on how to use 'cURL' command to send requests to a remote server in different protocols in URL format.

What Is "cURL"? - "cURL" is a client tool for Internet protocols represented in URL format.

Main features of "cURL":

Here are some examples of installing and using "wget" command.

1. Install "wget" on a CentOS computer.

herong$ sudo dnf install curl

...
Installed:
  curl-7.61.1-22.el8.x86_64

2. Download the home page on the local Web server. Received data is displayed to the console.

herong$ curl http://localhost

<html>
<body>
<p>Hello world!</p>
</body>
</html>

3. Download the home page on the local Web server, including both header and body parts.

herong$ curl --include http://localhost

HTTP/1.1 200 OK
Server: Apache/2.4.37 (centos) OpenSSL/1.1.1g
ETag: "73-5cbe9c0a43a66"
Accept-Ranges: bytes
Content-Length: 115
Content-Type: text/html; charset=UTF-8

<html>
...
</html>

4. Send a POST request with data to a Web site.

herong$ curl --data 'login=emma&password=123' --request POST \
  https://google.com/login

...

5. Display debugging information on an HTTPS request.

herong$ curl --verbose https://www.oracle.com/index.html
* Connected to www.oracle.com (23.63.32.30) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /usr/local/ssl/cacert.pem
  CApath: none
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [35 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [4369 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [79 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=California; L=Redwood City; O=Oracle Corporation; ...
*  start date: May 24 00:00:00 2022 GMT
*  expire date: Sep 17 23:59:59 2022 GMT
*  subjectAltName: host "www.oracle.com" matched cert's "www.oracle.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS Hybrid ECC ...
*  SSL certificate verify ok.
} [5 bytes data]
> GET /index.html HTTP/1.1
> Host: www.oracle.com
> User-Agent: curl/7.71.1
> Accept: */*

...

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Memory Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

Internet Networking Tools

 "wget" - Get Files from the Web

"cURL" - Client for URL

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB