curl 명령어 치트시트
curl 빠른 참조: HTTP 메서드, 헤더, 인증, JSON, 폼, 업로드, 다운로드, 리디렉트, 디버깅, 재시도와 연결 제어 — 자주 쓰는 옵션과 실전 예시까지 정리했습니다.
명령어 30개
기본
curl <url>URL 을 가져와 본문을 stdout 에 출력합니다.
-L 리디렉트 따라가기; -i 헤더 포함; -I HEAD 만; -v verbose; -s silent; -S 에러 표시; --compressed gzip/brotli 디코드
curl -L -s -o website.html https://example.com && curl -sI https://example.comcurl -O <url> / curl -o <file> <url>파일 다운로드: -O 는 원격 이름 유지, -o 는 지정한 경로로 저장.
-O; -o file; --create-dirs; --remove-on-error; -C - 이어받기; --retry N; --retry-delay N
curl -O https://nodejs.org/dist/v22.17.0/node-v22.17.0-linux-x64.tar.xz && curl -C - -O https://releases.example.com/sqldump.sqlHTTP 메서드 & 헤더
curl -X <METHOD> <url>특정 HTTP 메서드(POST/PUT/PATCH/DELETE...)를 강제합니다.
-X POST/PUT/PATCH/DELETE; --request-method; --request-target
curl -X DELETE -s https://api.example.com/users/42 && curl -X POST https://api.example.com/resetcurl -H 'Header: value' <url>사용자 정의 헤더를 한 개 이상 보냅니다(Content-Type, X-API-Key 등).
-H 'X-API-Key: ...'; -H 반복; --json (Content-Type + 페이로드); --form -F (multipart)
curl -s -H 'Authorization: Bearer $TOKEN' -H 'Accept: application/json' https://api.example.com/orders/1curl -A <agent> / -e <url>User-Agent 문자열 또는 Referer 를 설정합니다.
-A 'Mozilla/5.0 ...'; -e 'https://google.com'; --referer 별칭
curl -sA 'Mozilla/5.0 (X11; Linux)' -e 'https://google.com' https://example.com/articlecurl -i / -D headers.txt / -I <url>-i 는 헤더 인라인; -D 는 헤더를 파일로; -I 는 HEAD 만 보냄.
-i; -D <file>; -I; --dump-header <file>
curl -sI https://api.example.com/health && curl -D headers.txt -o body.json -s https://api.example.com/me인증
curl -u <user>:<password>HTTP Basic 인증(패스워드 옵션; 콜론만 적으면 프롬프트).
-u user:pass; --basic; -U readonly 특정 메서드
curl -u alice:'P@ssw0rd!' -s https://rest.example.com/private/list && curl -u alice -s https://rest.example.com/mecurl -H 'Authorization: Bearer <token>'Bearer 토큰을 보냅니다(--oauth2-bearer 로도 가능).
--oauth2-bearer $TOKEN; --bearer 별칭 (8+)
curl --oauth2-bearer '$GH_TOKEN' -s https://api.github.com/user | jq .logincurl --cert / --key / --cacertmTLS 용 클라이언트 인증서 / CA 번들을 사용합니다.
--cert certfile[:password]; --key key; --cacert ca.pem; --capath dir
curl --cert client.p12:P@ss --cacert ca.pem -s https://secure.internal/api && curl --cert cert.pem --key key.pem --cacert ca.pem https://...데이터 & 폼
curl -d '<body>' / -d @file / --data-raw / --data-binary요청 본문을 보냅니다(POST/PUT). -d 는 기본 폼 인코딩; --data-binary 는 바이트를 보존합니다.
-d 'a=b&c=d'; --data-raw; --data-binary @f; -G + --data-urlencode 로 쿼리스트링 구성
curl -s -X POST -d 'name=alice&[email protected]' https://api.example.com/users && curl --data-binary @body.json -H 'Content-Type: application/json' https://api.example.com/notescurl -F 'file=@/path'multipart/form-data 업로드(브라우저 표준 업로드 포맷)를 보냅니다.
-F field=value; -F file=@path; -F '[email protected];type=image/png'; --form-string raw
curl -s -F 'avatar=@./photo.png' -F 'name=alice' https://api.example.com/profilecurl -G --data-urlencodeURL 인코딩된 쿼리스트링을 만듭니다(값을 자동 URL 인코딩).
-G --data-urlencode 'q=hello world' --data-urlencode 'limit=10'
curl -sG --data-urlencode 'q=hello world' --data-urlencode 'page=2' https://api.example.com/searchJSON
curl -d @body.json -H 'Content-Type: application/json'요청 본문에 JSON 을 담아 보냅니다.
단축 --json (Content-Type + 페이로드를 한 플래그로)
curl -s --json @body.json -X POST https://api.example.com/orders && curl --json '{"a":1}' https://api.example.com/xcurl | jq '.'응답을 jq 로 파이프해 가독성 있는 / 필터링된 JSON 을 봅니다.
jq '. | {name,id}'; jq 'select(.id==42)'
curl -s https://api.github.com/repos/pnpm/pnpm/releases/latest | jq '{tag_name: .tag_name, name: .name, assets: [.assets[].name]}'쿠키 & 세션
curl -b cookies.txt / -c cookies.txt쿠키 읽기(b) / 쓰기(c). 첫 호출에 -j 를 함께 쓰면 리디렉트를 캡처합니다.
-c jar.txt 저장; -b "k=v" 리터럴; -b / -c /tmp/jar 같은 파일
curl -s -c /tmp/jar.txt -o /dev/null https://app.example.com/login && curl -s -b /tmp/jar.txt https://app.example.com/dashboardcurl --cookie-jar / --cookie-c / -b 의 긴 형태 별칭 — 스크립트에서 가독성을 위해 사용합니다.
curl --cookie-jar /tmp/jar --cookie /tmp/jar -s https://app.example.com/me디버그
curl -v / -vv / --trace-ascii자세한 핸드셰이크 추적; --trace 는 송수신 바이트를 덤프합니다.
-v / -vv / -vvv; --trace-ascii file; --trace file (binary)
curl -v --trace-ascii /tmp/login.trace https://api.example.com/logincurl --next연쇄 요청 사이에 플래그를 리셋("URL parm 0" / 연결 누수 방지).
--next; 호출별 리셋
curl -s -H 'Accept: text/html' https://example.com --next -s -H 'Accept: application/json' https://example.com/apicurl -w '%{http_code}\n'write-out 템플릿 정의 — 스크립트에서 상태/타이밍 검사에 유용.
-w 'status=%{http_code} time=%{time_total}\n'; --write-out
curl -s -o /dev/null -w 'status=%{http_code} time=%{time_total}s bytes=%{size_download}\n' https://example.com/health전송 & 재시도
curl -C - <url>중단된 지점부터 부분 다운로드를 이어받습니다.
-C -; --continue-at -
curl -C - -O https://releases.example.com/ubuntu-iso.isocurl --retry N --retry-delay S --retry-all-errors일시적 오류를 자동 재시도(네트워크, 5xx, reset).
--retry; --retry-delay; --retry-max-time; --retry-connrefused; --retry-all-errors (8+)
curl --retry 5 --retry-delay 5 --retry-all-errors --max-time 60 -O https://internal.example.com/big.zipcurl --limit-rate <speed> / --max-time <seconds>대역폭 사용량 또는 전체 실행 시간에 상한을 둡니다.
--limit-rate 200k; --max-time 30; --connect-timeout 5
curl --limit-rate 1M --max-time 600 -O https://releases.example.com/big.isocurl -T <file> <url>PUT 으로 파일을 업로드(HTTP PUT/RESUMABLE, -C - 와 결합).
-T file; --upload-file; -C - 로 이어받기; -H 'Authorization: ...' 와 결합
curl -T ./dist.tar.gz -H 'Authorization: Bearer $TOKEN' https://uploads.example.com/build/1.4.2.tar.gz연결
curl --interface <ip> / --dns-serversNIC 에 바인드(VPN 인터페이스 IP 사용) 또는 DNS 를 오버라이드 — split DNS 디버깅용.
--interface eth0:0; --dns-servers 1.1.1.1; --resolve 'host:port:ip' 호출별 오버라이드
curl --interface 10.99.0.1 -s https://api.internal.example.com && curl --resolve api.internal.example.com:443:127.0.0.1 -s https://api.internal.example.comcurl --http2 / --http3 / --tlsv1.2특정 프로토콜 또는 TLS 버전을 협상합니다.
--http2; --http2-prior-knowledge; --http3 (curl ≥ 7.88); --tls-max 1.3; --no-alpn
curl --http3 -sI https://cloudflare-quic.com && curl --tlsv1.2 -s https://api.example.comcurl --insecure / --cacertTLS 검증을 건너뛰거나 오버라이드(insecure = 디버그 전용).
-k / --insecure; --cacert ca.pem; --capath dir
curl -k --cacert dev-ca.pem -s https://localhost:8443/health설정
curl -K config.curl설정 파일로 curl 을 구동 — 반복 가능한 스크립트에 좋습니다.
--config file; 호출별 옵션
curl -sK - <<'EOF'\nurl = 'https://api.example.com/me'\nheader = 'Authorization: Bearer '$'${TOKEN}'\ncurl --parallel / --parallel-max단일 curl 인스턴스에서 여러 URL 을 동시에 실행(curl 7.68+).
--parallel; --parallel-immediate; --parallel-max N
curl --parallel --parallel-max 5 -sO https://example.com/img1.png -sO https://example.com/img2.png기타
curl --fail-with-body / -f / -fsSL스크립트에서 흔히 쓰는 URL 가져오기 관용구: silent, follow, HTTP 오류 시 실패, 출력.
-f / --fail; --fail-with-body 오류 시 본문 표시; -s silent; -L follow; -S 에러 표시
curl -fsSL -o installer.sh https://get.docker.com && sh installer.shcurl --compressed / --no-compressed--compressed 로 gzip/deflate/brotli 요청 — 대역폭 절약.
--compressed
curl --compressed -s -A 'Mozilla/5.0' https://news.example.com | head -c 200치트시트 버전 1.0.0
curl 7.88+ 대응