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
| Option | Bedeutung |
|---|---|
| -L | Follow redirects. curl does not follow them on its own, unlike a browser. |
| -i | Print 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 PUT | Override the method. Unnecessary with -d, which is already a POST. |
| -o <file> / -O | Save the body to a file / save it under the remote filename. |
| -s / -sS | No progress meter / silent but still print errors. |
| -f | Exit nonzero on HTTP 4xx and 5xx instead of printing the error page. |
| -k | Skip certificate verification. Debugging only, never in production. |
Beispiele
curl -fsSL https://example.com/install.sh -o install.shDownload quietly, follow redirects, fail loudly on a 404.
curl -i -H "Content-Type: application/json" -d '{"name":"a"}' https://api.example.com/itemsPOST JSON and read the response headers.
curl -s -o /dev/null -w "%{http_code}\n" https://example.comPrint 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