·터미널 명령어

curl

네트워크

쓰는 꼴

curl [options] <url>

주소 하나를 그대로 받아 본문을 화면에 뿌립니다 — 브라우저와 달리 `-L` 없이는 넘김을 따라가지 않아서, 301이 오면 빈 응답처럼 보입니다.

자주 쓰는 옵션

옵션
-LFollow redirects. curl does not follow them on its own, unlike a browser.
-iPrint the response headers along with the body; -I sends HEAD and prints headers only.
-d '{"a":1}'Send a request body. This alone already means POST.
-H "Content-Type: application/json"Add a request header; repeat -H for more.
-X PUTOverride the method. Unnecessary with -d, which is already a POST.
-o <file> / -OSave the body to a file / save it under the remote filename.
-s / -sSNo progress meter / silent but still print errors.
-fExit nonzero on HTTP 4xx and 5xx instead of printing the error page.
-kSkip certificate verification. Debugging only, never in production.

예시

curl -fsSL https://example.com/install.sh -o install.sh

Download quietly, follow redirects, fail loudly on a 404.

curl -i -H "Content-Type: application/json" -d '{"name":"a"}' https://api.example.com/items

POST JSON and read the response headers.

curl -s -o /dev/null -w "%{http_code}\n" https://example.com

Print just the status code.

연결이 안 될 때 어디까지 갔는지 좁혀 갑니다 — 이름이 안 풀리는지, 길이 없는지, 포트가 막혔는지.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. curl은 무엇을 하나요?

주소 하나를 그대로 받아 본문을 화면에 뿌립니다 — 브라우저와 달리 `-L` 없이는 넘김을 따라가지 않아서, 301이 오면 빈 응답처럼 보입니다.

Q. 어떻게 치나요?

curl [options] <url> — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 9개입니다. 전체 목록은 man curl에 있습니다. 이 명령은 네트워크 갈래입니다.

같이 보는 명령

man 페이지: man curl