GNU/Linux >> Belajar Linux >  >> Ubuntu

Perintah Linux curl Dijelaskan dengan Contoh

Pendahuluan

Mentransfer data ke dan dari server memerlukan alat yang mendukung protokol jaringan yang diperlukan. Linux memiliki beberapa alat yang dibuat untuk tujuan ini, yang paling populer adalah curl dan wget.

Tutorial ini akan menunjukkan cara menggunakan curl perintah dan memberi Anda daftar lengkap opsi yang tersedia.

Prasyarat

  • Akses ke terminal
  • Akses internet
  • curl terpasang

Apa Itu Perintah curl?

curl (kependekan dari "URL Klien") adalah alat baris perintah yang memungkinkan transfer data melalui berbagai protokol jaringan. Ini berkomunikasi dengan server web atau aplikasi dengan menentukan URL yang relevan dan data yang perlu dikirim atau diterima.

curl didukung oleh libcurl, perpustakaan transfer URL sisi klien portabel. Anda dapat menggunakannya langsung di baris perintah atau memasukkannya ke dalam skrip. Kasus penggunaan paling umum untuk curl adalah:

  • Mengunduh file dari internet
  • Pengujian titik akhir
  • Men-debug
  • Error saat masuk

Sintaks curl

curl dasar sintaksnya adalah sebagai berikut:

curl [options/URLs]

Misalnya:

curl https://www.gnu.org/gnu/gnu.html

Sistem mengeluarkan konten HTML yang ditemukan pada URL yang diberikan setelah curl perintah.

Jika Anda menentukan URL yang mengarah ke file, Anda dapat menggunakan curl untuk mengunduh file ke sistem lokal Anda:

curl [url] > [local-file]

Bilah kemajuan menunjukkan seberapa banyak file yang telah diunduh sejauh ini.

Sintaks URL yang merupakan bagian dari perintah bergantung pada protokol. Beberapa URL yang berbeda dalam satu bagian ditulis bersama menggunakan kurung kurawal:

http://example.{first,second,third}.com

Deret alfanumerik ditulis dengan tanda kurung:

ftp://ftp.url.com/file[1-100].txt

Meskipun urutan bersarang tidak didukung, beberapa urutan diperbolehkan:

http://url.com/archive[2010-2020]/vol[1-4]/part{a,b,c}.html

Protokol ikal

curl mendukung banyak protokol untuk transfer data. Temukan daftar lengkapnya di bawah ini.

Protokol Deskripsi
DICT Protokol jaringan kamus untuk menanyakan server kamus tentang arti kata.
FILE Skema URL untuk mendapatkan file dari sistem file lokal menggunakan curl.
FTP, FTPS Protokol Transfer File, digunakan untuk transfer file antara klien dan server. FTPS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
GOPHER, GOPHERS Protokol lama untuk mencari, mengambil, dan mendistribusikan dokumen internet, pendahulu HTTP. GOPHERS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
HTTP, HTTPS Hypertext Transfer Protocol, digunakan untuk transfer data web dan internet. HTTPS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
IMAP, IMAPS Protokol Akses Pesan Internet, digunakan untuk akses dan pengelolaan email. IMAPS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
LDAP, LDAPS Protokol Akses Direktori Ringan, digunakan untuk akses dan manajemen informasi direktori terdistribusi. LDAPS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
MQTT Transportasi Telemetri Antrian Pesan - protokol untuk pertukaran data antar perangkat kecil, biasanya sistem IoT.
POP3, POP3S Post Office Protocol versi 3 - protokol untuk pengambilan email dari server. POP3S adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
RTMP Protokol Pesan Real-Time - protokol streaming untuk audio, video, dan data lainnya.
RTSP Protokol Streaming Waktu Nyata, digunakan untuk manajemen server media streaming.
SCP Salin Aman - protokol untuk menyalin file ke dan dari server SSH.
SFTP Protokol Transfer File SSH - versi Protokol Transfer File yang menggunakan koneksi SSH.
UKM, UKM Server Message Block - protokol untuk mengelola akses bersama ke file dan periferal komputer. SMBS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
SMTP, SMPTS Protokol Transfer Surat Sederhana - protokol email untuk transmisi email yang mudah. SMTPS adalah versi protokol yang sama dengan lapisan keamanan SSL/TLS tambahan.
TELNET Protokol lapisan aplikasi untuk komunikasi berorientasi teks interaktif dua arah.
TFTP Protokol Transfer File Trivial, digunakan untuk mengunggah atau mengunduh file ke atau dari host jarak jauh.

Opsi Perintah curl

curl menerima beragam pilihan, yang menjadikannya perintah yang sangat serbaguna. Opsi dimulai dengan satu atau dua tanda hubung. Jika tidak memerlukan nilai tambahan, opsi tanda hubung tunggal dapat ditulis bersama. Misalnya, perintah yang menggunakan -O , -L , dan -v opsi dapat ditulis sebagai:

curl -OLv [url]

Daftar semua opsi yang tersedia diberikan di bawah ini.

Opsi Deskripsi
--abstract-unix-socket <path> Hubungkan melalui soket Unix abstrak, bukan melalui jaringan.

Contoh:
curl --abstract-unix-socket socketpath https://example.com
--alt-svc <file name> Aktifkan pengurai alt-svc.

Contoh:
curl --alt-svc svc.txt https://example.com
--anyauth Curl menemukan dan menggunakan metode autentikasi paling aman untuk URL HTTP yang diberikan.

Contoh:
curl --anyauth --user me:pass https://example.com
-a, --append Tambahkan ke file target.

Contoh:
curl --upload-file local --append ftp://example.com/
--aws-sigv4 <provider1[:provider2[:region[:service]]]> Gunakan otentikasi tanda tangan AWS V4.

Contoh:
curl --aws-sigv4 "aws:amz:east-2:es" --user "key:secret" https://example.com
--basic Gunakan otentikasi dasar HTTP.

Contoh:
curl -u name:password --basic https://example.com
--cacert <file> Gunakan file yang ditentukan untuk verifikasi sertifikat.

Contoh:
curl --cacert CA-file.txt https://example.com
--capath <dir> Gunakan direktori yang ditentukan untuk mencari sertifikat.

Contoh:
curl --capath /local/directory https://example.com
--cert-status Verifikasi status sertifikat server.

Contoh:
curl --cert-status https://example.com
--cert-type <type> Tentukan jenis sertifikat yang disediakan. Jenis yang dikenali adalah PEM (default), DER , ENG dan P12 .

Contoh:
curl --cert-type ENG --cert file https://example.com
-E, --cert <certificate[:password]> Gunakan file sertifikat yang disediakan saat bekerja dengan protokol berbasis SSL.

Contoh:
curl --cert certfile --key keyfile https://example.com
--ciphers <list of ciphers> Menyediakan cipher untuk digunakan dalam koneksi.

Contoh:
curl --ciphers ECDHE-ECDSA-AES256-CCM8 https://example.com
--compressed-ssh Aktifkan kompresi SSH bawaan.

Contoh:
curl --compressed-ssh sftp://example.com/
--compressed Permintaan untuk menerima respons terkompresi.

Contoh:
curl --compressed https://example.com
-K, --config <file> Sediakan file teks dengan argumen curl, alih-alih menulisnya di baris perintah.

Contoh:
curl --config file.txt https://example.com
--connect-timeout <fractional seconds> Tentukan waktu maksimum koneksi curl dapat bertahan.

Contoh:
curl --connect-timeout 30 https://example.com
--connect-to <HOST1:PORT1:HOST2:PORT2> Menyediakan aturan koneksi untuk mengarahkan permintaan pada node cluster server tertentu.

Contoh:
curl --connect-to example.com:443:example.net:8443 https://example.com
-C, --continue-at <offset> Lanjutkan transfer file pada offset yang ditentukan.

curl -C 400 https://example.com
-c, --cookie-jar <filename> Tentukan file untuk menyimpan cookie.

curl -c store.txt https://example.com
-b, --cookie <data|filename> Membaca cookie dari sebuah file.

Contoh:
curl -b cookiefile https://example.com
--create-dirs Buat direktori lokal untuk --output pilihan.

Contoh:
curl --create-dirs --output local/dir/file https://example.com
--create-file-mode <mode> Tentukan mode mana yang akan disetel pada pembuatan file.

Contoh:
curl --create-file-mode 0777 -T localfile sftp://example.com/new
--crlf Konversi LF ke CRLF.

curl --crlf -T file ftp://example.com/
--crlfile <file> Berikan Daftar Pencabutan Sertifikat untuk sertifikat rekan.

curl --crlfile revoke.txt https://example.com
--curves <algorithm list> Menyediakan kurva untuk membuat sesi SSL.

Contoh:
curl --curves X25519 https://example.com
--data-ascii <data> Lihat -d , --data .

Contoh:
curl --data-ascii @file https://example.com
--data-binary <data> Poskan data seperti yang ditentukan, tanpa pemrosesan tambahan.

curl --data-binary @filename https://example.com
--data-raw <data> Sama seperti -d , --data , tetapi karakter @ tidak diperlakukan berbeda dari yang lain.

curl --data-raw "@[email protected]@" https://example.com
--data-urlencode <data> Sama seperti -d , --data , tetapi lakukan penyandian URL.

Contoh:
curl --data-urlencode name=val https://example.com
-d, --data <data> Kirim data ke server HTTP dalam permintaan POST.

Contoh:
curl -d "name=curl" https://example.com
--delegation <LEVEL> Tentukan kapan server diizinkan untuk mendelegasikan kredensial.

Contoh:
curl --delegation "always" https://example.com
--digest Aktifkan otentikasi Intisari HTTP.

Contoh:
curl -u name:password --digest https://example.com
--disable-eprt Nonaktifkan perintah EPRT dan LPRT untuk transfer FTP aktif.

Contoh:
curl --disable-eprt ftp://example.com/
--disable-epsv Nonaktifkan EPSV untuk transfer FTP pasif.

Contoh:
curl --disable-epsv ftp://example.com/
-q, --disable Nonaktifkan pembacaan file konfigurasi curlrc.

curl -q https://example.com 
--disallow-username-in-url Keluar jika diberikan URL yang berisi nama pengguna.

Contoh:
curl --disallow-username-in-url https://example.com
--dns-interface <interface> Tentukan antarmuka untuk permintaan DNS keluar.

Contoh:
curl --dns-interface eth0 https://example.com
--dns-ipv4-addr <address> Tentukan alamat IPv4 dari mana permintaan DNS akan datang.

Contoh:
curl --dns-ipv4-addr 10.1.2.3 https://example.com
--dns-ipv6-addr <address> Tentukan alamat IPv6 dari mana permintaan DNS akan datang.

Contoh:
curl --dns-ipv6-addr 2a04:4e42::561 https://example.com
--dns-servers <addresses> Tentukan daftar server DNS Anda sendiri.

Contoh:
curl --dns-servers 192.168.0.1,192.168.0.2 https://example.com
--doh-cert-status --cert-status untuk DNS-over-HTTPS.

Contoh:
curl --doh-cert-status --doh-url https://doh.server https://example.com 
--doh-insecure -k , --insecure untuk DoH.

Contoh:
curl --doh-insecure --doh-url https://doh.server https://example.com
--doh-url <URL> Tentukan server DoH untuk resolusi nama host.

Contoh:
curl --doh-url https://doh.server https://example.com 
-D, --dump-header <filename> Tentukan file untuk menulis header protokol.

Contoh:
curl --dump-header store.txt https://example.com 
--egd-file <file> Berikan jalur untuk soket EGD.

Contoh:
curl --egd-file /path/here https://example.com 
--engine <name> Tentukan mesin kripto OpenSSL.

Contoh:
curl --engine flavor https://example.com 
--etag-compare <file> Meminta ETag membaca dari file.

Contoh:
curl --etag-compare etag.txt https://example.com 
--etag-save <file> Simpan HTTP ETag ke file.

Contoh:
curl --etag-save etag.txt https://example.com 
--expect100-timeout <seconds> Waktu tunggu maksimum untuk respons 100 lanjutan.

Contoh:
curl --expect100-timeout 2.5 -T file https://example.com 
--fail-early Beri tahu curl untuk gagal dan keluar saat mendeteksi kesalahan pertama dalam transfer.

Contoh:
curl --fail-early https://example.com https://two.example 
--fail-with-body Jika server mengembalikan kesalahan dengan kode 400 atau lebih besar, curl menyimpan konten dan mengembalikan kesalahan 22.

Contoh:
curl --fail-with-body https://example.com 
-f, --fail Jika server mengembalikan kesalahan, curl gagal secara diam-diam dan mengembalikan kesalahan 22.

Contoh:
curl --fail https://example.com 
--false-start Gunakan awal yang salah pada jabat tangan TLS.

Contoh:
curl --false-start https://example.com 
--form-string <name=string> Mirip dengan -F , --form , tetapi string nilai diproses secara harfiah.

Contoh:
curl --form-string "data" https://example.com 
-F, --form <name=content> Meniru formulir dengan Kirim tombol yang telah ditekan. @ tanda memaksa konten menjadi file. < tanda mengekstrak hanya bagian konten file.

Contoh:
curl --form "name=curl" --form "[email protected]" https://example.com
--ftp-account <data> Tentukan data akun untuk server FTP.

Contoh:
curl --ftp-account "account_data" ftp://example.com/
--ftp-alternative-to-user <command> Tentukan perintah yang akan dikirim jika otentikasi nama pengguna dan sandi gagal.

Contoh:
curl --ftp-alternative-to-user "U53r" ftp://example.com 
--ftp-create-dirs Jika direktori yang ditentukan tidak ada, curl akan mencoba membuatnya.

Contoh:
curl --ftp-create-dirs -T file ftp://example.com/dirs/one/file 
--ftp-method <method> Tentukan metode yang akan digunakan untuk mendapatkan file melalui FTP. Metode yang tersedia adalah multicwd , nocwd , dan singlecwd .

Contoh:
curl --ftp-method multicwd ftp://example.com/dir1/dir2/file 
--ftp-pasv Gunakan mode koneksi data pasif.

Contoh:
curl --ftp-pasv ftp://example.com/ 
-P, --ftp-port <address> Membalikkan peran default untuk koneksi FTP.

Contoh:
curl -P eth0 ftp:/example.com 
--ftp-pret Kirim perintah PRET sebelum PASV/EPSV.

Contoh:
curl --ftp-pret ftp://example.com/ 
--ftp-skip-pasv-ip Jangan gunakan alamat IP yang disarankan oleh server. curl akan menggunakan IP koneksi kontrol.

Contoh:
curl --ftp-skip-pasv-ip ftp://example.com/ 
--ftp-ssl-ccc-mode <active/passive> Setel mode Hapus Saluran Perintah (CCC).

Contoh:
curl --ftp-ssl-ccc-mode active --ftp-ssl-ccc ftps://example.com/ 
--ftp-ssl-ccc Setelah otentikasi selesai, lapisan SSL/TLS dihilangkan, memungkinkan komunikasi yang tidak terenkripsi.

Contoh:
curl --ftp-ssl-ccc ftps://example.com/ 
--ftp-ssl-control Gunakan SSL/TLS untuk login, hentikan enkripsi saat transfer data dimulai.

Contoh:
curl --ftp-ssl-control ftp://example.com 
-G, --get Gunakan permintaan GET HTTP alih-alih POST.

Contoh:
curl --get -d "tool=curl" -d "age=old" https://example.com
-g, --globoff Nonaktifkan parser globbing URL.

Contoh:
curl -g "https://example.com/{[]}}}}" 
--happy-eyeballs-timeout-ms <milliseconds> Gunakan algoritme Happy Eyeballs untuk menghubungkan ke host tumpukan ganda.

Contoh:
curl --happy-eyeballs-timeout-ms 500 https://example.com 
--haproxy-protocol Gunakan header protokol HAProxy PROXY v1.

Contoh:
curl --haproxy-protocol https://example.com 
-I, --head Dapatkan hanya tajuk.

Contoh:
curl -I https://example.com 
-H, --header <header/@file> Tentukan header tambahan yang akan dikirim dalam permintaan HTTP.

Contoh:
curl -H "X-First-Name: Joe" https://example.com 
-h, --help <category> Lihat bantuan untuk kategori tertentu. all daftar semua opsi yang tersedia.

Contoh:
curl --help all 
--hostpubmd5 <md5> Meneruskan string heksadesimal 32 digit.

Contoh:
curl --hostpubmd5 e5c1c49020640a5ab0f2034854c321a8 sftp://example.com/ 
--hsts <file name> Aktifkan HSTS.

Contoh:
curl --hsts cache.txt https://example.com 
--http0.9 Terima respons HTTP versi 0.9.

Contoh:
curl --http0.9 https://example.com
-0, --http1.0 Gunakan HTTP versi 1.0.

Contoh:
curl --http1.0 https://example.com
--http1.1 Gunakan HTTP versi 1.1.

Contoh:
curl --http1.1 https://example.com 
--http2-prior-knowledge Gunakan HTTP versi 2.0. Gunakan opsi ini jika Anda tahu bahwa server mendukung versi HTTP ini.

Contoh:
curl --http2-prior-knowledge https://example.com
--http2 Coba gunakan HTTP versi 2.0.

Contoh:
curl --http2 https://example.com
--http3 Gunakan HTTP versi 3.0. Ini adalah opsi eksperimental.

Contoh:
curl --http3 https://example.com
--ignore-content-length Abaikan header Content-Length.

Contoh:
curl --ignore-content-length https://example.com
-i, --include Tentukan bahwa output harus menyertakan header respons HTTP.

Contoh:
curl -i https://example.com
-k, --insecure Izinkan curl bekerja dengan koneksi yang tidak aman.

Contoh:
curl --insecure https://example.com 
--interface <name> Tentukan antarmuka untuk melakukan tindakan.

Contoh:
curl --interface eth0 https://example.com 
-4, --ipv4 Hanya tentukan nama ke alamat IPv4.

Contoh:
curl --ipv4 https://example.com 
-6, --ipv6 Hanya selesaikan nama ke alamat IPv6.

Contoh:
curl --ipv6 https://example.com
-j, --junk-session-cookies Buang cookie sesi.

Contoh:
curl --junk-session-cookies -b cookies.txt https://example.com 
--keepalive-time <seconds> Tentukan waktu idle untuk koneksi sebelum mengirimkan probe keepalive.

Contoh:
curl --keepalive-time 30 https://example.com 
--key-type <type> Tentukan jenis kunci pribadi. Jenis yang tersedia adalah PEM (default), DER , dan ENG .

Contoh:
curl --key-type ENG --key here https://example.com 
--key <key> Tentukan file yang berisi kunci pribadi.

Contoh:
curl --cert certificate --key here https://example.com 
--krb <level> Aktifkan dan gunakan otentikasi Kerberos. Level yang tersedia clear , safe , confidential , dan private (bawaan).

Contoh:
curl --krb clear ftp://example.com/ 
--libcurl <file> Dapatkan kode sumber C untuk operasi baris perintah yang ditentukan.

Contoh:
curl --libcurl client.c https://example.com 
--limit-rate <speed> Tentukan kecepatan transfer unggah dan unduhan maksimum.

Contoh:
curl --limit-rate 100K https://example.com 
-l, --list-only Paksa tampilan hanya nama.

Contoh:
curl --list-only ftp://example.com/dir/ 
--local-port <num/range> Tentukan nomor port yang akan digunakan untuk koneksi.

Contoh:
curl --local-port 1000-3000 https://example.com 
--location-trusted Mirip dengan -L , --location , tetapi memungkinkan Anda mengirim nama dan sandi ke semua pengalihan.

Contoh:
curl --location-trusted -u user:pass https://example.com
-L, --location Izinkan curl mengikuti pengalihan apa pun.

Contoh:
curl -L https://example.com 
--login-options <options> Tentukan opsi login untuk otentikasi server email.

Contoh:
curl --login-options 'AUTH=*' imap://example.com 
--mail-auth <address> Berikan satu alamat sebagai identitas.

Contoh:
curl --mail-auth [email protected] -T mail smtp://example.com/ 
--mail-from <address> Berikan satu alamat "dari".

Contoh:
curl --mail-from [email protected] -T mail smtp://example.com/ 
--mail-rcpt-allowfails Memungkinkan curl untuk melanjutkan percakapan SMTP jika salah satu penerima gagal.

Contoh:
curl --mail-rcpt-allowfails --mail-rcpt [email protected] smtp://example.com 
--mail-rcpt <address> Berikan satu alamat "ke".

Contoh:
curl --mail-rcpt [email protected] smtp://example.com 
-M, --manual Baca manual curl.

Contoh:
curl --manual 
--max-filesize <bytes> Berikan ukuran maksimum file yang akan diunduh.
Contoh:
curl --max-filesize 500K https://example.com 
--max-redirs <num> Tentukan jumlah pengalihan maksimum saat --location aktif.

Contoh:
curl --max-redirs 3 --location https://example.com 
-m, --max-time <fractional seconds> Tentukan waktu maksimum untuk operasi.

Contoh:
curl --max-time 5.52 https://example.com 
--metalink Tentukan sumber daya metallink. Opsi ini dinonaktifkan di curl versi terbaru.

Contoh:
curl --metalink file https://example.com 
--negotiate Aktifkan autentikasi SPNEGO.

Contoh:
curl --negotiate -u : https://example.com
--netrc-file <filename> Suka --n , --netrc , tetapi memungkinkan Anda untuk menentukan file yang akan digunakan.

Contoh:
curl --netrc-file netrc https://example.com 
--netrc-optional Suka --n , --netrc , tetapi menggunakan netrc adalah opsional.

Contoh:
curl --netrc-optional https://example.com 
-n, --netrc Cari file netrc untuk informasi login.

Contoh:
curl --netrc https://example.com 
-:, --next Gunakan opsi untuk memisahkan permintaan URL.

Contoh:
curl -I https://example.com --next https://example.net/ 
--no-alpn Nonaktifkan ekstensi ALPN TLS.

Contoh:
curl --no-alpn https://example.com 
-N, --no-buffer Nonaktifkan buffer aliran keluaran.

Contoh:
curl --no-buffer https://example.com 
--no-keepalive Nonaktifkan pesan keepalive.

Contoh:
curl --no-keepalive https://example.com 
--no-npn Nonaktifkan ekstensi NPN TLS.

Contoh:
curl --no-npn https://example.com 
--no-progress-meter Nonaktifkan bilah kemajuan tetapi tampilkan pesan lainnya.

Contoh:
curl --no-progress-meter -o store https://example.com 
--no-sessionid Nonaktifkan caching ID sesi SSL.

Contoh:
curl --no-sessionid https://example.com 
--noproxy <no-proxy-list> Daftar host yang tidak boleh menggunakan proxy.

Contoh:
curl --noproxy "www.example" https://example.com 
--ntlm-wb Suka --ntlm , tetapi juga menyerahkan otentikasi ke ntlmauth.

Contoh:
curl --ntlm-wb -u user:password https://example.com 
--ntlm Aktifkan otentikasi NTLM.

Contoh:
curl --ntlm -u user:password https://example.com 
--oauth2-bearer <token> Berikan Token Pembawa untuk OAUTH 2.0.

Contoh:
curl --oauth2-bearer "mF_9.B5f-4.1JqM" https://example.com 
--output-dir <dir> Tentukan direktori file keluaran.

Contoh:
curl --output-dir "tmp" -O https://example.com 
-o, --output <file> Simpan keluaran dalam sebuah file. Outputnya tidak ditampilkan di stdout.

Contoh:
curl -o file https://example.com -o file2 https://example.net 
--parallel-immediate Lebih suka koneksi paralel daripada menunggu koneksi baru atau aliran multipleks.

Contoh:
curl --parallel-immediate -Z https://example.com -o file1 https://example.com -o file2
--parallel-max <num> Tentukan jumlah maksimum koneksi paralel.

Contoh:
curl --parallel-max 100 -Z https://example.com ftp://example.com/ 
-Z, --parallel Lakukan transfer secara paralel.

Contoh:
curl --parallel https://example.com -o file1 https://example.com -o file2
--pass <phrase> Tentukan frasa sandi kunci pribadi.

Contoh:
curl --pass secret --key file https://example.com 
--path-as-is Cegah ikal dari penggabungan /./ dan /../ urutan.

Contoh:
curl --path-as-is https://example.com/../../etc/passwd
--pinnedpubkey <hashes> Tentukan kunci publik untuk curl yang akan digunakan.

Contoh:
curl --pinnedpubkey keyfile https://example.com 
--post301 Cegah curl mengonversi permintaan POST ke GET setelah pengalihan 301.

Contoh:
curl --post301 --location -d "data" https://example.com 
--post302 Cegah curl mengonversi permintaan POST ke GET setelah pengalihan 302.

curl --post302 --location -d "data" https://example.com 
--post303 Cegah curl mengonversi permintaan POST ke GET setelah pengalihan 303.

Contoh:
curl --post303 --location -d "data" https://example.com 
--preproxy [protocol://]host[:port] Gunakan proxy SOCKS sebagai pra-proksi.

Contoh:
curl --preproxy socks5://proxy.example -x http://http.example https://example.com 
-#, --progress-bar Gunakan bilah kemajuan sederhana.

Contoh:
curl -# -O https://example.com 
--proto-default <protocol> Tentukan protokol curl mana yang harus digunakan untuk URL tanpa nama skema.

Contoh:
curl --proto-default https ftp.example.com 
--proto-redir <protocols> Tentukan protokol curl mana yang harus digunakan pada pengalihan.

Contoh:
curl --proto-redir =http,https https://example.com 
--proto <protocols> Tentukan protokol curl mana yang harus digunakan untuk transfer.

Contoh:
curl --proto =http,https,sftp https://example.com 
--proxy-anyauth Curl harus memilih metode otentikasi yang sesuai.

Contoh:
curl --proxy-anyauth --proxy-user user:passwd -x proxy https://example.com
--proxy-basic Gunakan HTTP Basic untuk komunikasi dengan proxy.

Contoh:
curl --proxy-basic --proxy-user user:passwd -x proxy https://example.com 
--proxy-cacert <file> --cacert untuk proxy HTTPS.

Contoh:
curl --proxy-cacert CA-file.txt -x https://proxy https://example.com 
--proxy-capath <dir> --capath for HTTPS proxies.

Contoh:
curl --proxy-capath /local/directory -x https://proxy https://example.com
--proxy-cert-type <type> --cert-type for HTTPS proxies.

Contoh:
curl --proxy-cert-type PEM --proxy-cert file -x https://proxy https://example.com
--proxy-cert <cert[:passwd]> -E , --cert for HTTPS proxies.

Contoh:
curl --proxy-cert file -x https://proxy https://example.com 
--proxy-ciphers <list> --ciphers for HTTPS proxies.

curl --proxy-ciphers ECDHE-ECDSA-AES256-CCM8 -x https://proxy https://example.com 
--proxy-crlfile <file> --crlfile for HTTPS proxies.

Contoh:
curl --proxy-crlfile rejects.txt -x https://proxy https://example.com
--proxy-digest Use HTTP Digest authentication with a proxy.

Contoh:
curl --proxy-digest --proxy-user user:passwd -x proxy https://example.com 
--proxy-header <header/@file> -H , --header for proxy communication.

Contoh:
curl --proxy-header "Host:" -x http://proxy https://example.com 
--proxy-insecure -k , --insecure for HTTPS proxies.

Contoh:
curl --proxy-insecure -x https://proxy https://example.com 
--proxy-key-type <type> --key-type for HTTPS proxies.

Contoh:
curl --proxy-key-type DER --proxy-key here -x https://proxy https://example.com 
--proxy-key <key> --key for HTTPS proxies.

Contoh:
curl --proxy-key here -x https://proxy https://example.com 
--proxy-negotiate --negotiate for proxy communication.

Contoh:
curl --proxy-negotiate --proxy-user user:passwd -x proxy https://example.com
--proxy-ntlm Use HTTP NTLM authentication with a proxy.

Contoh:
curl --proxy-ntlm --proxy-user user:passwd -x http://proxy https://example.com
--proxy-pass <phrase> --pass for HTTPS proxies.

Contoh:
curl --proxy-pass secret --proxy-key here -x https://proxy https://example.com 
--proxy-pinnedpubkey <hashes> Specify the public key for proxy verification.

Contoh:
curl --proxy-pinnedpubkey keyfile https://example.com 
--proxy-service-name <name> Specify the service name for proxy communciation.

Contoh:
curl --proxy-service-name "shrubbery" -x proxy https://example.com 
--proxy-ssl-allow-beast --ssl-allow-beast for HTTPS proxies.

Contoh:
curl --proxy-ssl-allow-beast -x https://proxy https://example.com 
--proxy-ssl-auto-client-cert --ssl-auto-client-cert for HTTPS proxies.

Contoh:
curl --proxy-ssl-auto-client-cert -x https://proxy https://example.com 
--proxy-tls13-ciphers <ciphersuite list> Specifies the list of cipher suites to use in negotiating TLS 1.3 for proxies.

Contoh:
curl --proxy-tls13-ciphers TLS_AES_128_GCM_SHA256 -x proxy https://example.com
--proxy-tlsauthtype <type> --tlsauthtype for HTTPS proxies.

Contoh:
curl --proxy-tlsauthtype SRP -x https://proxy https://example.com 
--proxy-tlspassword <string> --tlspassword for HTTPS proxies.

Contoh:
curl --proxy-tlspassword passwd -x https://proxy https://example.com 
--proxy-tlsuser <name> --tlsuser for HTTPS proxies.

Contoh:
curl --proxy-tlsuser smith -x https://proxy https://example.com 
--proxy-tlsv1 -1 , --tlsv1 for HTTPS proxies.

Contoh:
curl --proxy-tlsv1 -x https://proxy https://example.com 
-U, --proxy-user <user:password> Specify the username and password for authenticating with a proxy.

Contoh:
curl --proxy-user name:pwd -x proxy https://example.com 
-x, --proxy [protocol://]host[:port] Specify a proxy to use.

Contoh:
curl --proxy http://proxy.example https://example.com 
--proxy1.0 <host[:port]> Specify a HTTP 1.0 proxy to use.

Contoh:
curl --proxy1.0 -x http://proxy https://example.com 
-p, --proxytunnel Create a proxy tunnel.

Contoh:
curl --proxytunnel -x http://proxy https://example.com 
--pubkey <key> Provide a file containing a public key.

Contoh:
curl --pubkey file.pub sftp://example.com/ 
-Q, --quote <command> Send a command to a FTP or SFTP server, to be executed before the transfer.

Contoh:
curl --quote "rm file" ftp://example.com/foo 
--random-file <file> Specify a file containing random data. This file will be used for seeding the random engine.

Contoh:
curl --random-file rubbish https://example.com 
-r, --range <range> Obtain a range of bytes.

Contoh:
curl --range 40-80 https://example.com 
--raw Disable HTTP content decoding and obtain raw data.

Contoh:
curl --raw https://example.com 
-e, --referer <URL> Send Referrer Page information.

Contoh:
curl --referer "https://test.example" https://example.com 
-J, --remote-header-name Use header name specified by the server instead of obtaining it from the URL.

Contoh:
curl -OJ https://example.com/file 
--remote-name-all Apply the -O , --remote-name option to all the URLs.

Contoh:
curl --remote-name-all ftp://example.com/file1 ftp://example.com/file2 
-O, --remote-name Specify that the local file should have the name of the remote file that was downloaded.

Contoh:
curl -O https://example.com/filename 
-R, --remote-time Specify that the local file should have the timestamp of the remote file that was downloaded.

Contoh:
curl --remote-time -o foo https://example.com 
--request-target <path> Specify an alternative target path.

Contoh:
curl --request-target "*" -X OPTIONS https://example.com 
-X, --request <command> Specify a request method for communication with the server.

Contoh:
curl -X "DELETE" https://example.com 
--resolve <[+]host:port:addr[,addr]...> Specify a custom address for a host/port.

Contoh:
curl --resolve example.com:443:127.0.0.1 https://example.com 
--retry-all-errors Force retrying on all errors.

Contoh:
curl --retry-all-errors https://example.com 
--retry-connrefused Add ECONNREFUSED to the list of errors that are eligible for --retry .

Contoh:
curl --retry-connrefused --retry https://example.com 
--retry-delay <seconds> Specify the amount of time between retries.

Contoh:
curl --retry-delay 5 --retry https://example.com 
--retry-max-time <seconds> Specify the maximum amount of time for --retry attempts.

Contoh:
curl --retry-max-time 30 --retry 10 https://example.com 
--retry <num> Specify the number of retries after curl encounters and error.

Contoh:
curl --retry 7 https://example.com
--sasl-authzid <identity> Specify an additional authentication identity for SASL PLAIN authentication.

Contoh:
curl --sasl-authzid zid imap://example.com/ 
--sasl-ir Enable initial response during SASL authentication.

Contoh:
curl --sasl-ir imap://example.com/ 
--service-name <name> Specify the SPNEGO service name.

Contoh:
curl --service-name sockd/server https://example.com 
-S, --show-error Show an error message event with the -s , --silent option enabled.

Contoh:
curl --show-error --silent https://example.com 
-s, --silent Turn on the silent mode. This option mutes curl.

Contoh:
curl -s https://example.com 
--socks4 <host[:port]> Specify a SOCKS4 proxy.

Contoh:
curl --socks4 hostname:4096 https://example.com 
--socks4a <host[:port]> Specify a SOCKS4a proxy.

Contoh:
curl --socks4a hostname:4096 https://example.com 
--socks5-basic Use the basic authentication method (username/password) with a SOCKS5 proxy.

Contoh:
curl --socks5-basic --socks5 hostname:4096 https://example.com 
--socks5-gssapi-nec Allow protection mode negotiation to be unprotected.

Contoh:
curl --socks5-gssapi-nec --socks5 hostname:4096 https://example.com 
--socks5-gssapi-service <name> Change the name of a socks server.

Contoh:
curl --socks5-gssapi-service sockd --socks5 hostname:4096 https://example.com 
--socks5-gssapi Use GSS-API authentication with a SOCKS5 proxy.

Contoh:
curl --socks5-gssapi --socks5 hostname:4096 https://example.com 
--socks5-hostname <host[:port]> Specify the SOCKS5 proxy to use.

Contoh:
curl --socks5-hostname proxy.example:7000 https://example.com 
--socks5 <host[:port]> Specify the SOCKS5 proxy to use. The hostname is resolved locally.

Contoh:
curl --socks5 proxy.example:7000 https://example.com 
-Y, --speed-limit <speed> Set the lower limit for the download speed.

Contoh:
curl --speed-limit 300 --speed-time 10 https://example.com 
-y, --speed-time <seconds> Set the time period for the speed limit measurement.

Contoh:
curl --speed-limit 300 --speed-time 10 https://example.com 
--ssl-allow-beast Tell curl to ignore the BEAST security flaw in the SSL3 and TLS1.0 protocols.

Contoh:
curl --ssl-allow-beast https://example.com 
--ssl-auto-client-cert Obtain and use a client certificate automatically.

Contoh:
curl --ssl-auto-client-cert https://example.com 
--ssl-no-revoke Do not check for certificate revocation.

Contoh:
curl --ssl-no-revoke https://example.com 
--ssl-reqd Require SSL/TLS.

Contoh:
curl --ssl-reqd ftp://example.com 
--ssl-revoke-best-effort Ignore certificate revocation checks if they failed because of missing distribution points.

Contoh:
curl --ssl-revoke-best-effort https://example.com 
--ssl Attempt to use SSL.

Contoh:
curl --ssl pop3://example.com/ 
-2, --sslv2 Use SSLv2. Newer curl versions ignore this request due to security concerns with SSLv2.

Contoh:
curl --sslv2 https://example.com 
-3, --sslv3 Use SSLv3. Newer curl versions ignore this request due to security concerns with SSLv3.

Contoh:
curl --sslv3 https://example.com 
--stderr <file> Output stderr to a file. The - symbol tells curl to output stderr to stdout.

Contoh:
curl --stderr output.txt https://example.com 
--styled-output Enable bold fonts for HTTP header terminal output.

curl --styled-output -I https://example.com 
--suppress-connect-headers Prevent curl from outputting CONNECT headers.

Contoh:
curl --suppress-connect-headers --include -x proxy https://example.com 
--tcp-fastopen Enable TCP Fast Open.

Contoh:
curl --tcp-fastopen https://example.com
--tcp-nodelay Enable TCP_NODELAY.

Contoh:
curl --tcp-nodelay https://example.com 
-t, --telnet-option <opt=val> Pass the TTYPE , XDISPLOC , and NEW_ENV options to the telnet protocol.

Contoh:
curl -t TTYPE=vt100 telnet://example.com/ 
--tftp-blksize <value> Set the value of TFTP BLKSIZE. Must be a value larger than 512.

Contoh:
curl --tftp-blksize 1024 tftp://example.com/file 
--tftp-no-options Prevents curl from sending requests for TFTP options.

Contoh:
curl --tftp-no-options tftp://192.168.0.1/ 
-z, --time-cond <time> Request a document that was modified after a certain date and time. For documents modified before the time, prefix the date expression with a dash.

Contoh:
curl -z "Wed 01 Sep 2021 12:18:00" https://example.com 
--tls-max <VERSION> Specify the newest TLS version that is supported.

Contoh:
curl --tls-max 1.2 https://example.com 
--tls13-ciphers <ciphersuite list> Specifies the list of cipher suites to use in negotiating TLS 1.3

Contoh:
curl --tls13-ciphers TLS_AES_128_GCM_SHA256 https://example.com 
--tlsauthtype <type> Specify the TLS authentication type.

Contoh:
curl --tlsauthtype SRP https://example.com 
--tlspassword <string> Specify the TLS password.

Contoh:
curl --tlspassword pwd --tlsuser user https://example.com 
--tlsuser <name> Specify the TLS username.

Contoh:
curl --tlspassword pwd --tlsuser user https://example.com 
--tlsv1.0 Tell curl to use TLS1.0 or newer.

Contoh:
curl --tlsv1.0 https://example.com 
--tlsv1.1 Tell curl to use TLS1.1 or newer.

Contoh:
curl --tlsv1.1 https://example.com 
--tlsv1.2 Tell curl to use TLS1.2 or newer.

Contoh:
curl --tlsv1.2 https://example.com 
--tlsv1.3 Tell curl to use TLS1.3 or newer.

Contoh:
curl --tlsv1.3 https://example.com 
-1, --tlsv1 Specify that curl should use at least 1.x version of TLS.

Contoh:
curl --tlsv1 https://example.com 
--tr-encoding Ask for a compressed Transfer-Encoding response.

Contoh:
curl --tr-encoding https://example.com 
--trace-ascii <file> Enable a full trace dump to a file. Eliminates the hex part and shows only ASCII.

Contoh:
curl --trace-ascii log.txt https://example.com 
--trace-time Require a time stamp on each trace or verbose line.

Contoh:
curl --trace-time --trace-ascii output https://example.com 
--trace <file> Enable a full trace dump to a file.

Contoh:
curl --trace log.txt https://example.com 
--unix-socket <path> Specify a Unix socket path.

Contoh:
curl --unix-socket socket-path https://example.com 
-T, --upload-file <file> Upload a file to the URL.

Contoh:
curl -T "img[1-1000].png" ftp://ftp.example.com/ 
--url <url> Provide a URL to be fetched.

Contoh:
curl --url https://example.com 
-B, --use-ascii Enable ASCII transfer.

Contoh:
curl -B ftp://example.com/README 
-A, --user-agent <name> Specify the user agent name.

Contoh:
curl -A "Agent 007" https://example.com 
-u, --user <user:password> Provide the username and password for authentication.

Contoh:
curl -u user:secret https://example.com 
-v, --verbose Tell curl to be verbose.

Contoh:
curl --verbose https://example.com 
-V, --version See the installed versions of curl and libcurl.

Contoh:
curl --version 
-w, --write-out <format> Tell curl to show information about the completed transfer on stdout.

Contoh:
curl -w '%{http_code}\n' https://example.com 
--xattr Store file metadata in file attributes.

Contoh:
curl --xattr -o storage https://example.com 

For comprehensive descriptions of the options, execute the curl --manual command in the terminal.


Ubuntu
  1. Perintah shutdown Linux Dijelaskan dengan Contoh

  2. Perintah JQ di Linux dengan Contoh

  3. Perintah Procinfo di Linux Dijelaskan dengan contoh

  1. Perintah Sumber Linux dengan Contoh

  2. Perintah wc Linux dengan Contoh

  3. Perintah Traceroute Linux, Dijelaskan dengan Contoh

  1. Perintah potong Linux Dijelaskan dengan 6 Contoh

  2. Perintah Curl di Linux dengan Contoh

  3. Perintah ip Linux dengan Contoh