Hacker News new | ask | show | jobs
by du_bing 3513 days ago
What is the biggest usage of Curl? I am new to Linux,sorry.
10 comments

The biggest usage is probably not the tool itself, but the library.

It's the de-facto-standard-HTTP-library (although it does more than just HTTP). E.g. if you have a PHP script that downloads some data from another webpage it very often does this with curl.

Apart from the oodles of software that depends on curl/libcurl, my favourite thing is to "Copy as cURL" from a Chrome request.
Or Firefox, but yes, first to debug all web bugs!
It's handy for giving an API endpoint a slap without needing a scripting language
The underlying library (libcurl) is extremely useful on all platforms, not just Linux.
I find it very useful for debugging. For example, when you have a web server that redirects requests saying:

  curl --verbose --location URL
or even

  curl --trace --location URL
provides the desired information.
Data transfer by many protocols using URLs. See their website https://curl.haxx.se for details.

Super tool, we use it all the time for file transfers

I use for a few things, almost every day.

Getting my outgoing ip address (to check net connectivity): curl ip.mydomain.net or (to force ipv4) curl -4 ip.mydomain.net

To check how a page redirects: curl -v example.com (shows headers)

Interacting with elasticsearch, mainly showing indexes and their health: curl localhost:9200/_cat/indices

It's used to send an http/HTTPS reqeuests, controlling every aspect of it, form headers to cookies, to ignoring/not SSL certs, and has advanced debugging option to show you the entire dialog (-sv) and use a different IP address (--resolve to test you firewalls, LBs etc...).
It sure does quite a lot and I love it, but I wish it could handle SIP and WebSockets without too much trouble.
File transfers, getting http headers, getting html content of a page piping it to a script to clean it up and read later (long articles).

That's what I use it for, I think, mainly.

Edit: also between php scripts

curl is a trusted way to execute unsafe code on the internet

https://gnu.moe/wallofshame.md

"curl | sh" is no worse than "wget && tar xf && ./configure". I have yet to see anyone who knows how to audit a configure script generated by GNU autoconf, which is generally a multiple-tens-of-thousands-of-line monstrosity that generates a bunch of C files and compiles and runs them. FUD about "curl | sh" isn't rooted in any sensible security modeling.

As a general rule of thumb, if you think everyone around you is independently doing something stupid, you should first pursue the hypothesis that it is your reasoning that is flawed and not the entire rest of the world's.

But you're verifying the signature of the tarball first, right?
Almost all of the examples on that page use curl https:// | sh. Which, again, makes it a superior option to wget && gpg --verify && ./configure; I have yet to see anyone who is better at PGP fingerprint verification than their OS's SSL stack is at TLS certificate verification. (There are a very small number of people who are as good, but not better.)