curl Linux Command
Transfers data from or to a server using various protocols (HTTP, FTP, etc.).
What does curl do?
Transfers data from or to a server using various protocols (HTTP, FTP, etc.).
Syntax
curl [options] URLPractical example
curl -I https://example.comQuestions about curl
How do I download a file with curl?
Use `curl -O URL` to download a file with its original name, or `curl -o filename URL` to specify a custom name.
How do I see HTTP headers?
Use `curl -I URL` to fetch only the HTTP headers without downloading the body. This is useful for checking response codes and content types.
How do I follow redirects with curl?
Use `curl -L URL` to follow HTTP redirects (301, 302). Without `-L`, curl will show the redirect response instead of the final content.
How do I make a POST request?
Use `curl -X POST -d 'data' URL` to send a POST request with data. Use `-H` to set headers like Content-Type.
How do I send JSON data with curl?
Use `curl -X POST -H 'Content-Type: application/json' -d '{"key":"value"}' URL` to send JSON.
How do I use curl with authentication?
Use `curl -u username:password URL` for basic authentication, or `-H 'Authorization: Bearer TOKEN'` for token-based auth.
How do I download a file silently?
Use `curl -s -O URL` to download silently without progress meter. The `-s` flag suppresses all output except errors.
How do I check if a website is up?
Use `curl -I https://example.com` and check the HTTP status code. A 200 OK means the site is responding normally.
Related Networking Commands
ssModern replacement for netstat. Dumps socket statistics quickly.
wgetDownloads files from the internet non-interactively via HTTP, HTTPS, or FTP.
netstatDisplays network connections, routing tables, interface statistics, and more.
digPerforms DNS lookups and displays detailed name server query information.
ipModern replacement for ifconfig. Shows and manipulates routing, devices, and tunnels.
nslookupQueries DNS servers to resolve domain names to IP addresses and vice versa.