Interview Q&A / Linux & Shell

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What do the curl flags -s, -L, -o, -f and -I do?

SHORT ANSWER

-s hides the progress meter, -L follows redirects, -o saves the body to a file, -f makes curl fail with a non-zero exit code on HTTP errors, and -I fetches only the headers. A common combination in scripts is curl -fsSL.

Explain it simply

By default curl is quiet about failure: a 404 page is printed like a success and the exit code is 0. Scripts need the flags below to behave properly.

  • -s silent: no progress bar. Pair with -S so real errors still show.
  • -L follow redirects. Without it, a 301 from http to https returns an empty page.
  • -o file save the body to a named file; -O uses the remote file name.
  • -f fail on HTTP errors (400 and above): no body, exit code 22.
  • -I HEAD request: print only response headers.
  • -w '%{http_code}' prints the status code after the transfer.

The common installer pattern curl -fsSL URL | bash means: be quiet, fail properly, show errors, follow redirects. It is convenient but dangerous: you run unseen code, so download first and read it.

Example

bash
code=$(curl -s -o /dev/null -w '%{http_code}' https://example.com)
echo "$code"
# 200
curl -fsSL -o get.sh https://example.com/get.sh || echo "download failed"

What to say in the interview

"-s quiets progress, -L follows redirects, -o saves to a file, -f turns HTTP errors into a failing exit code and -I fetches headers only. In scripts I use -fsSL and check the exit status, or -w to read the status code."

Common mistakes

  • Assuming curl exits non-zero on a 404; it does not without -f.
  • Piping curl straight into bash without reading the script.

#linux#networking#curl

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.