Use the command line frequently, such as curl, to test interface response times

for i in {1.10.};do curl -o /dev/null -s   -w "$i | time_namelookup: %{time_namelookup} | time_connect: %{time_connect} | time_starttransfer: %{time_starttransfer} | time_total: %{time_total}\n" "http://httpbin.org/ip"; done1 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.125000 | time_total: 0.141000
2 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.094000 | time_total: 0.109000
3 | time_namelookup: 0.016000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000
4 | time_namelookup: 0.015000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000
5 | time_namelookup: 0.031000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000
6 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.094000 | time_total: 0.109000
7 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.125000 | time_total: 0.125000
8 | time_namelookup: 0.000001 | time_connect: 0.016000 | time_starttransfer: 0.141000 | time_total: 0.141000
9 | time_namelookup: 0.015000 | time_connect: 0.015000 | time_starttransfer: 0.093000 | time_total: 0.109000
10 | time_namelookup: 0.000001 | time_connect: 0.015000 | time_starttransfer: 0.109000 | time_total: 0.125000
Copy the code

What if I cannot remember too many command line parameters? This is when you need a man, and he is a man

man

#man curl curl(1) Curl Manual curl(1) NAME curl - transfer a URL SYNOPSIS curl [options] [URL...]  DESCRIPTION curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction. curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin! curl is powered by libcurl for all transfer-related features. See libcurl(3) for details. URL The URL syntax is protocol-dependent. You'll find a detailed description in RFC 3986. You can specify multiple URLs or parts of URLs by writing part sets within braces as in: http://site.{one,two,three}.com or you can get sequences of alphanumeric series by using [] as in: ftp://ftp.numericals.com/file[1-100].txt ftp://ftp.numericals.com/file[001-100].txt (with leading zeros) ftp://ftp.letters.com/file[a-z].txtCopy the code

Men are really tough, giving so many hints, but nothing I really want… I still don’t know how to use it.

You’ll probably see TL in technical articles a lot; DR is Too Long; Man Curl is too long for me to Read.

This is the stronger Man TLDR, it is a command line tool, directly using NPM install -g TLDR to install.

tldr

/ root @ VM_0_14_centos ~ # NPM install - g TLDR/usr/local/n/versions/node / 11.4.0 / bin/TLDR - > / usr/local/n/versions/node / 11.4.0 / lib/node_modules/TLDR/bin/TLDR + [email protected] added 113 packages from 103 contributors In 60.759 s ╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │ New minor version of NPM available! 6.4.1-6.9.0 │ │ Changelog: https://github.com/npm/cli/releases/tag/v6.9.0 │ │ Run NPM install - g NPM to update! │ │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯Copy the code

After the installation, see how TLDR works by itself.

$ tldr tldr

  tldr

  Simplified man pages.
  More information: .

  - Get typical usages of a command (hint: thisis how you got here!) : tldr command - Show the tar tldr pagefor linux:
    tldr -p linux tar

  - Get help for a git subcommand:
    tldr git checkout

Copy the code

A little test run

$ tldr -p linux tar

  tar

  Archiving utility.
  Often combined with a compression method, such as gzip or bzip.
  More information: .

  - Create an archive from files:
    tar -cf target.tar file1 file2 file3

  - Create a gzipped archive:
    tar -czf target.tar.gz file1 file2 file3

  - Extract an archive in a target directory:
    tar -xf source.tar -C directory

  - Extract a gzipped archive in the current directory:
    tar -xzf source.tar.gz

  - Extract a bzipped archive in the current directory:
    tar -xjf source.tar.bz2

  - Create a compressed archive, using archive suffix to determine the compression program:
    tar -caf target.tar.xz file1 file2 file3

  - List the contents of a tar file:
    tar -tvf source.tar

  - Extract files matching a pattern:
    tar -xf source.tar --wildcards "*.html"

Copy the code

Curl curl curl curl curl curl curl curl curl

λ tldr curl

  curl

  Transfers data from or to a server.
  Supports most protocols, including HTTP, FTP, and POP3.

  - Download the contents of an URL to a file:
    curl http://example.com -o filename

  - Download a file, saving the output under the filename indicated by the URL:
    curl -O http://example.com/filename

  - Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:
    curl -O -L -C - http://example.com/filename

  - Send form-encoded data (POST request of type application/x-www-form-urlencoded):
    curl -d 'name=bob' http://example.com/form

  - Send a request with an extra header, using a custom HTTP method:
    curl -H 'X-My-Header: 123' -X PUT http://example.com

  - Send data in JSON format, specifying the appropriate content-type header:
    curl -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users/1234

  - Pass a user name and password for server authentication:
    curl -u myusername:mypassword http://example.com

  - Pass client certificate and key for a resource, skipping certificate validation:
    curl --cert client.pem --key key.pem --insecure https://example.com
Copy the code

This man is stronger than the other guy. I like the curl command.

In addition to the built-in commands, installation commands can also be used

[root@VM_0_14_centos ~]# tldr python

  python

  Python language interpreter.
  More information: https://www.python.org.

  - Call a Python interactive shell (REPL):
    python

  - Execute script in a given Python file:
    python script.py

  - Execute script as part of an interactive shell:
    python -i script.py

  - Execute a Python expression:
    python -c "expression"

  - Run library module as a script (terminates option list):
    python -m module arguments

  - Interactively debug a Python script:
    python -m pdb script.py
Copy the code

There are other versions besides Node github.com/tldr-pages/… For Python, PIP install TLDR is installed directly

If you don’t want to install TLDR, you can also use the web page to check out https://tldr.sh/

github.com/cheat/cheat
pip install cheat

cheat

Let’s see how cheat works

$ cheat cheat # To see example usage of a program: cheat <command> # To edit a cheatsheet cheat -e <command> # To list available cheatsheets cheat -l # To search available  cheatsheets cheat -s <command> # To get the current `cheat' version cheat -vCopy the code

Try the curl

$ cheat curl # Download a single file curl http://path.to.the/file # Download a file and specify a new filename curl http://example.com/file.zip -o new_file.zip # Download multiple files curl -O URLOfFirstFile -O URLOfSecondFile # Download all sequentially numbered files (1-24) curl http://example.com/pic[1-24].jpg # Download a file and pass HTTP Authentication curl -u username:password URL # Download a file with a Proxy curl -x proxysever.server.com:PORT http://addressiwantto.access # Download a file from FTP curl -u username:password -O ftp://example.com/pub/file.zip # Get an FTP directory listing curl ftp://username:[email protected] # Resume a previously failed download curl -C - -o  partial_file.zip http://example.com/file.zip # Fetch only the HTTP headers from a response curl -I http://example.com #  Fetch your external IP and network info as JSON curl http://ifconfig.me/all/json # Limit the rate of a download curl --limit-rate 1000B -O http://path.to.the/file # Get your global IP curl httpbin.org/ip # Get only the HTTP status code curl -o /dev/null -w '%{http_code}\n' -s -I URL $ cheat python # Desc: Python is a high-level programming language. # Basic example of server with python # Will start a Web Server in the Current Directory on port 8000 # go to http://127.0.0.1:8000 # Python v2.7 Python -m SimpleHTTPServer # Python 3 Python -m http.server 8000 # SMTP-Server for debugging, messages will be discarded, and printed on stdout. python -m smtpd -n -c DebuggingServer localhost:1025 # Pretty print a json python -mjson.toolCopy the code

More detailed than TLDR, you can use curl if you don’t want to install it

cht.sh

[root@VM_0_14_centos ~]# curl cht.sh/curl # Download a single file curl http://path.to.the/file # Download a file and specify a new filename curl http://example.com/file.zip -o new_file.zip # Download multiple files curl -O URLOfFirstFile  -O URLOfSecondFile # Download all sequentially numbered files (1-24) curl http://example.com/pic[1-24].jpg # Download a  file and follow redirects curl -L http://example.com/file # Download a file and pass HTTP Authentication curl -u username:password URL # Download a file with a Proxy curl -x proxysever.server.com:PORT http://addressiwantto.access # Download a file from FTP curl -u username:password -O ftp://example.com/pub/file.zip # Get an FTP directory listing curl  ftp://username:[email protected] # Resume a previously failed download curl -C - -o partial_file.zip http://example.com/file.zip # Fetch only the HTTP headers from a response curl -I http://example.com # Fetch your external IP and network info as JSON curl http://ifconfig.me/all/json # Limit the rate of a download curl --limit-rate 1000B -O http://path.to.the/file # POST to a form curl -F "name=user" -F "password=test" http://example.com # POST JSON Data curl -H "Content-Type: application/json" -X POST -d '{"user":"bob","pass":"123"}' http://example.com # POST data from the standard in / share data on sprunge.us curl -F 'sprunge=<-' sprunge.usCopy the code

See how Python requests is used

[root@VM_0_14_centos ~]# curl cheat.sh/python/requests # python-requests: Limit Number of Redirects Followed # # You have to create Session (http://www.python- # requests.org/en/latest/api/requests.Session) object and set # max_redirects variable to 3 session = requests.Session() session.max_redirects = 3 session.get(url) # TooManyRedirects exception will be raised if a requests exceeds # maximum number of redirects. # # Related github issue discussing why you can not set max_redirects per # request https://github.com/kennethreitz/requests/issues/1300 # # [Alik] [so/q / 31552627] [cc by - sa 3.0]Copy the code

It also has a web version of cht.sh/curl

Win under my command line tool is CMder, if you use win10, you can try the latest release of Microsoft Terminal github.com/microsoft/T…

resources

Microsoft’s best command line tool

Linux command daqo search tool

Quick tutorial on Linux tools

Interesting Linux command line tools

Art of the command Line

Three command line tools that pretend to be busy

28 UNIX/LINUX command-line artifacts

Command line tool

PHPer a must know must know Linux command

Recommended reading:

All those browser quirks you probably didn’t know about

All those weird wechat tricks you probably didn’t know about

All those weird tweets you probably didn’t know about

Those who you may not know NetEase cloud music strange technology lewd qiao

All those search tricks you probably didn’t know about

Videos you probably didn’t know about

Free VIP videos that you probably didn’t know about

Public account: Su Sheng no doubt