Improved readability

This commit is contained in:
Michele Cereda
2022-11-18 09:11:30 +01:00
parent 7856ad9a76
commit 55dd844f3e
3 changed files with 41 additions and 32 deletions

View File

@@ -23,17 +23,18 @@ cloud-init devel schema --config-file '/tmp/user-data'
# Check the raw logs.
cat '/var/log/cloud-init.log'
cat '/var/log/cloud-init-output.log'
# Parse and organize cloud-init.log events by stage.
# Parse and organize the events in the log file by stage.
cloud-init analyze show
# Manually run a single cloud-config module onceafter the instance has booted.
# Manually run a single cloud-config module once after the instance has booted.
sudo cloud-init single --name 'cc_ssh' --frequency 'always'
# Clean up everything so cloud-init can re-run.
# Clean up everything so `cloud-init` can run again.
sudo cloud-init clean
# Re-run all.
# Re-run everything.
sudo cloud-init init
```
@@ -75,11 +76,15 @@ package_reboot_if_required: false
# https://cloudinit.readthedocs.io/en/latest/topics/examples.html#install-arbitrary-packages
#
# docker-ce already depends on docker-ce-cli and containerd.io
packages:
packages:
- docker-ce
- jq
- unzip
# Enable and start the service after installation
runcmd:
- systemctl daemon-reload
- systemctl enable --now docker.service
```
## Merge 2 or more files or parts

View File

@@ -4,63 +4,63 @@
```sh
# Send a single GET request and show its output on stdout.
curl http://url.of/file
curl 'http://url.of/file'
# Be quiet.
curl --silent https://www.example.com
curl -s --show-error https://www.example.com
curl --silent 'https://www.example.com'
curl -s --show-error 'https://www.example.com'
# Download files.
curl http://url.of/file -o path/to/file
curl -O http://url.of/file1 -O http://url.of/file2
curl 'http://url.of/file' -o 'path/to/file'
curl -O 'http://url.of/file1' -O 'http://url.of/file2'
curl http://url.of/file[1-24]
# Resume downloads.
curl -C - -o partial_file http://url.of/file
curl -C - -o 'partial_file' 'http://url.of/file'
# Limit downloads bandwidth.
curl --limit-rate 1000B -O http://url.of/file
curl --limit-rate '1000B' -O 'http://url.of/file'
# Follow redirects.
curl -L http://url.of/file
curl -L 'http://url.of/file'
# Only fetch HTTP headers from a response.
curl -I http://example.com
curl -I 'http://example.com'
# Only return the HTTP status code.
curl -o /dev/null -w '%{http_code}\n' -s -I http://example.com
curl -o '/dev/null' -w '%{http_code}\n' -s -I 'http://example.com'
# Send different request types.
curl --request PUT http://example.com
curl --request 'PUT' 'http://example.com'
# Specify headers.
curl http://example.com -H "Content-Type:application/json" http://example.com
curl 'http://example.com' -H 'Content-Type:application/json' 'http://example.com'
# Skip certificate validation.
curl --insecure https://example.com
curl --insecure 'https://example.com'
# Pass certificates for a resource.
curl --cert client.pem --key key.pem -k https://example.com
curl --cacert ca.pem https://example.com
curl --cert 'client.pem' --key 'key.pem' -k 'https://example.com'
curl --cacert 'ca.pem' 'https://example.com'
# Authenticate.
curl -u username:password http://url.of/file
curl -u username:password -O ftp://url.of/file
curl ftp://username:password@example.com
curl -u 'username':'password' 'http://url.of/file'
curl -u 'username':'password' -O 'ftp://url.of/file'
curl 'ftp://username:password@example.com'
# POST to a form.
curl -F "name=user" -F "password=test" http://example.com
curl --data 'name=bob' http://example.com/form
curl -F 'name=user' -F 'password=test' 'http://example.com'
curl --data 'name=bob' 'http://example.com/form'
# Send data.
curl http://example.com -H "Content-Type:application/json" -d '{"name":"bob"}' -X POST
curl http://example.com -H "Content-Type:application/json" -d @file.json -X POST
curl 'http://example.com' -H "Content-Type:application/json" -d '{"name":"bob"}' -X 'POST'
curl -d @file.json
# Use a proxy.
curl http://example.com --proxy socks5://localhost:19999
curl 'http://example.com' --proxy 'socks5://localhost:19999'
# Forcefully resolve a host to a given address.
curl https://example.com --resolve example.com:443:google.com
curl 'https://example.com' --resolve 'example.com:443:google.com'
```
## Apply settings to all connections

View File

@@ -13,10 +13,14 @@
## TL;DR
```sh
# Check port 22 on hosts.
# Check ports on hosts.
nc -Nnvz 192.168.0.81 22
parallel -j 0 "nc -Nnvz -w 2 192.168.0.{} 22 2>&1" ::: {2..254} | grep -v "timed out"
nc -Nvz host.name 443
# List hosts with a specific port open.
parallel -j 0 "nc -Nnvz -w 2 192.168.0.{} 22 2>&1" ::: {2..254} \
| grep -v "timed out"
# Wait for a host to be up.
until nc -Nvz -w 3 pi4.lan 22; do sleep 3; done
until nc -Nvz -w 3 pi.lan 22; do sleep 3; done
```