vim /etc/sysconfig/docker


OPTIONS='--registry-mirror= --selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then

A Few cURL Tips for Daily Use

Though I knew cURL as a powerful tool; so far I never made an attempt to get familiar with it. Most of the time, I would just wade through its man pages to find a way get my stuff done. Recently I found myself make use of it for many of my daily tasks. By those excess usage, couple of recurring patterns emerged.

If you are already familiar with cURL, you may not find anything interesting or new here (but feel free to point out any improvements or other useful tips in comments).

Resume failed downloads

cURL has this handy option (

-C or --continue-at

) to set a transfer offset, which helps to resume failed downloads. On most cases, setting the offset as a single dash, will let cURL to decide how to resume the download.

  curl -C - -L -O

It’s a shame that I came to know about this very recently. I would now be cursing lot less at my ISP.

Fetch request body from a file

Nowadays, most web service APIs demand request bodies to be formatted as JSON. Manually entering a JSON formatted string in command-line is not a very convenient option. Better way to do it would be to prepare the request body in a file and provide it to cURL.

Here’s an example of creating a gist, providing the payload from a JSON file.

  curl -d @input.json

Start the data parameter with a @ to tell cURL, it should fetch the file in given path.

Mimic AJAX requests

Sometimes I need create endpoints in web apps, that produces alternate responses when accessed via AJAX (eg. not rendering the layout). Testing them directly in browser is not much viable as it require bootstrapping code. Instead, we can mimic AJAX requests from cURL by providing X-Requested-With header.

  curl -H "X-Requested-With: XMLHttpRequest"

Store and Use Cookies

Another similar need is to test the behavior of cookies. Especially, when you want to alter a response depending on a cookie value.

You can use cURL to download the response cookies to a file and then use them on the subsequent requests. You can inspect the cookie file and even alter it to test the desired behavior.

  curl -L -c cookies.txt 
  curl -L -b cookies.txt

View a web page as GoogleBot

When I was running this blog with WordPress, Google marked it as a site infected with malware. Panicked, I visited the site and checked the source. I couldn’t see anything suspicious. Later I discovered, the malware is only injected to the site only when it is accessed by the GoogleBot. So how do you see a site’s output as GoogleBot?

cURL’s option (

-A or --user-agent

) to change the user-agent of a request comes handy on such instances. Here’s how you can impersonate GoogleBot:

  curl -L -A "Googlebot/2.1 (+"

Peep into others’ infrastructure

This is not exactly a cURL feature, but comes in handy when I want to find out what others’ use to power their apps/sites.

  curl -s -L -I | grep Server


1. 等值比较: =
2. 等值比较:< =>
3. 不等值比较: <>和!=
4. 小于比较: < 5. 小于等于比较: <= 6. 大于比较: >
7. 大于等于比较: >=
8. 区间比较
9. 空值判断: IS NULL
10. 非空判断: IS NOT NULL
10. LIKE比较: LIKE
1. 加法操作: +
2. 减法操作: –
3. 乘法操作: *
4. 除法操作: /
5. 取余操作: %
6. 位与操作: &
7. 位或操作: |
8. 位异或操作: ^
9.位取反操作: ~

Download single files from GitHub

Git does not support downloading parts of the repository. You have to download all of it. But you should be able to do this with GitHub.

When you view a file it has a link to the “raw” version. The URL is constructed like so

By filling in the blanks in the URL, you can use Wget or cURL or whatever to download a single file. Again, you won’t get any of the nice version control features used by Git by doing this.

Update: I noticed you mention this doesn’t work for binary files. You probably shouldn’t use binary files in your Git repository, but GitHub has a download section for each repository that you can use to upload files. If you need more than one binary, you can use a .zip file. The URL to download an uploaded file is:



  • 我名欧阳锋,自三流本科毕业,辗转北上广,后来自主创业,自此已经虚度30几个春秋。五六年前告别打工的生涯,自主创业,在甘肃兰州,接了点私活,注册了西度软件外包公司。说是公司,其实一瓶一钵而已,知道内情的人都了解我这个公司其实就是个皮包公司,遇到客人来访,发点小礼品,做个活动,骗一些在校生过来凑个人数。生意好的的时候,一年接七八单,再外包出去,中间做点差价,赚点小钱,虽然不多,也不用在企业里受人指手画脚,闲暇时间喝点小酒,生活倒也过得惬意。当然生活也有拮据的时候,这是候要钱会狠一点,也因为这点,江湖上人送外号西毒。