Start·Terminal-Befehle

curl

Netzwerk

Aufruf

curl [options] <url>

Holt eine URL und schreibt den Body ins Terminal; anders als ein Browser folgt es ohne `-L` keinen Weiterleitungen, sodass ein 301 wie eine leere Antwort aussieht.

Häufige Optionen

OptionBedeutung
-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.

Beispiele

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.

Wenn eine Verbindung scheitert, grenzen diese ein, wie weit sie kam — Name löst nicht auf, keine Route, oder der Port ist zu.

So liest man das

  • Eckige Klammern [ ] markieren einen Teil, den man weglassen kann.
  • Drei Punkte … heißen: mehrere sind erlaubt.
  • Optionen achten auf Groß- und Kleinschreibung — bei manchen Befehlen sind -r und -R verschieden.

Häufige Fragen

Q. Was macht curl?

Holt eine URL und schreibt den Body ins Terminal; anders als ein Browser folgt es ohne `-L` keinen Weiterleitungen, sodass ein 301 wie eine leere Antwort aussieht.

Q. Wie gibt man ihn ein?

curl [options] <url> — eckige Klammern markieren, was wegfallen darf.

Q. Wie viele Optionen lohnen sich?

Hier stehen 9; die vollständige Liste steht in man curl. Der Befehl gehört zu Netzwerk.

Verwandte Befehle

man-Seite: man curl