From 0adbf033480514d89b27e91fc78d2f8948870d2f Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 22 Nov 2020 13:10:48 +0100 Subject: [PATCH] Fix comment length in all first-level cheat sheets * sheets/MegaCli * sheets/az * sheets/azure * sheets/blktrace * sheets/emacs * sheets/exim * sheets/go * sheets/ipython * sheets/jq * sheets/nmap * sheets/perl * sheets/psql * sheets/redis * sheets/sed * sheets/smartctl * sheets/solidity * sheets/yq_v4 --- sheets/MegaCli | 6 +++--- sheets/az | 43 ++++++++++++++++++++++++------------------- sheets/azure | 19 ++++++++++++------- sheets/blktrace | 3 ++- sheets/emacs | 3 ++- sheets/exim | 6 ++++-- sheets/go | 6 ++++-- sheets/ipython | 21 ++++++++++++--------- sheets/jq | 7 ++++--- sheets/nmap | 15 ++++++++++----- sheets/perl | 6 ++++-- sheets/psql | 14 +++++++++----- sheets/redis | 3 ++- sheets/sed | 17 ++++++++++------- sheets/smartctl | 2 +- sheets/solidity | 6 ++++-- sheets/yq_v4 | 9 ++++++--- 17 files changed, 113 insertions(+), 73 deletions(-) diff --git a/sheets/MegaCli b/sheets/MegaCli index bfdda54..dc5e906 100644 --- a/sheets/MegaCli +++ b/sheets/MegaCli @@ -1,5 +1,6 @@ -# MegaCli introduced by LSI as a command line administration of LSI MegaRaid controllers. -# With megacli we can create physical raids, gather info about raids and monitor raids. +# MegaCli +# A command line administration of LSI MegaRaid controllers. +# It allows to create physical raids, gather info about raids and monitor raids. # Install MegaCLI yum install MegaCli # CentOS @@ -21,4 +22,3 @@ MegaCli -PDInfo -PhysDrv [E:S] -aALL # Battery backup information MegaCli -AdpBbuCmd -aALL - diff --git a/sheets/az b/sheets/az index ef34bba..119f6d9 100644 --- a/sheets/az +++ b/sheets/az @@ -4,11 +4,14 @@ # Install Azure CLI 2.0 with one curl command. curl -L https://aka.ms/InstallAzureCli | bash -# create a resource group named "MyResourceGroup" in the westus2 region of Azure -az group create -n MyResourceGroup -l westus2 +# create a resource group named "MyRG" in the 'westus2' region +az group create -n MyRG -l westus2 -# create a Linux VM using the UbuntuTLS image, with two attached storage disks of 10 GB and 20 GB -az vm create -n MyLinuxVM -g MyResourceGroup --ssh-key-value $HOME/.ssh/id_rsa.pub --image UbuntuLTS --data-disk-sizes-gb 10 20 +# create a Linux VM using the UbuntuTLS image, +# with two attached storage disks of 10 GB and 20 GB +az vm create -n MyLinuxVM -g MyRG \ + --ssh-key-value $HOME/.ssh/id_rsa.pub --image UbuntuLTS \ + --data-disk-sizes-gb 10 20 # list VMs az vm list --output table @@ -16,28 +19,28 @@ az vm list --output table # list only VMs having distinct state az vm list -d --query "[?powerState=='VM running']" --output table -# delete VM (with the name MyLinuxVM in the group MyResourceGroup) -az vm delete -g MyResourceGroup -n MyLinuxVM --yes +# delete VM (with the name MyLinuxVM in the group MyRG) +az vm delete -g MyRG -n MyLinuxVM --yes # Delete all VMs in a resource group -az vm delete --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv) +az vm delete --ids $(az vm list -g MyRG --query "[].id" -o tsv) # Create an Image based on a running VM -az vm deallocate -g MyResourceGroup -n MyLinuxVM -az vm generalize -g MyResourceGroup -n MyLinuxVM -az image create --resource-group MyResourceGroup --name MyTestImage --source MyLinuxVM +az vm deallocate -g MyRG -n MyLinuxVM +az vm generalize -g MyRG -n MyLinuxVM +az image create --resource-group MyRG --name MyTestImage --source MyLinuxVM # Running VM based on a VHD az storage blob upload --account-name "${account_name}" \ - --account-key "${account_key}" --container-name "${container_name}" --type page \ - --file "${file}" --name "${vhd_name}" + --account-key "${account_key}" --container-name "${container}" --type page \ + --file "${file}" --name "${vhd}" az disk create \ - --resource-group ${resource_group} \ + --resource-group "${resource_group}" \ --name myManagedDisk \ - --source https://${account_name}.blob.core.windows.net/${container_name}/${vhd_name} + --source "https://${account_name}.blob.core.windows.net/${container}/${vhd}" # open port -az vm open-port --resource-group MyResourceGroup --name MyLinuxVM --port 443 --priority 899 +az vm open-port --resource-group MyRG --name MyLinuxVM --port 443 --priority 899 # Show storage accounts az storage account list --output table @@ -46,7 +49,8 @@ az storage account list --output table az storage container list --account-name mystorageaccount --output table # Show blobs in a container -az storage blob list --account-name mystorageaccount --container-name mycontainer --output table +az storage blob list --account-name mystorageaccount \ + --container-name mycontainer --output table # list account keys az storage account keys list --account-name STORAGE_NAME --resource-group RESOURCE_GROUP @@ -62,8 +66,8 @@ az disk list --output table # Copy blob az storage blob copy start \ - --source-uri 'https://md-ldh5nknx2rkz.blob.core.windows.net/jzwuuuzzapn0/abcd?sv=2017-04-17&sr=b&si=68041718-6828-4f5e-9e6e-a1b719975062&sig=XXX' \ - --account-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX== \ + --source-uri 'https://xxx.blob.core.windows.net/jzwuuuzzapn0/abcd?...' \ + --account-key XXXXXXXXXX== \ --account-name destaccount \ --destination-container vms \ --destination-blob DESTINATION-blob.vhd @@ -81,7 +85,8 @@ az vm list-ip-addresses --output table az snapshot create --resource-group IC-EXASOL-001 --source vm1-disk1 -n vm1-snap1 # create SAS url for a snapshot -az snapshot grant-access --resource-group IC-EXASOL-001 --name vm1-snap1 --duration-in-seconds 36000 --query '[accessSas]' -o tsv +az snapshot grant-access --resource-group IC-EXASOL-001 --name vm1-snap1\ + --duration-in-seconds 36000 --query '[accessSas]' -o tsv # attach disk az vm disk attach --vm-name vm1 -g RESOURCE_GROUP --disk DISK1_ID diff --git a/sheets/azure b/sheets/azure index b80c711..89303b1 100644 --- a/sheets/azure +++ b/sheets/azure @@ -10,13 +10,14 @@ azure login azure login -u # This will login in using a service principal -azure login -u "" -p "" --service-principal --tenant "" +azure login -u "" -p "" --service-principal --tenant "" # find images with Linux in name azure vm image list | grep "Linux" # start a new VM (in asm mode) -azure vm create ${vm_name} ${image_name} -u ${azureuser} -p "${password}" -z "Small" -e -l "West US" +azure vm create ${vm_name} ${image_name} -u ${azureuser} \ + -p "${password}" -z "Small" -e -l "West US" # List VMs disks azure vm disk list @@ -24,24 +25,28 @@ azure vm disk list # Remove all disks of VMs labeled with LABEL for disk in $(azure vm disk list | grep LABEL | awk '{print $2}') do - azure vm disk delete --blob-delete "$disk" + azure vm disk delete --blob-delete "$disk" done # Create storage account $myacct in location 'West US' -azure storage account create ${storage_account} --label ${storage_account} --location 'West US' +azure storage account create ${stor_acc} \ + --label ${stor_acc} --location 'West US' # Set default account environment variables export AZURE_STORAGE_ACCOUNT=$account_name export AZURE_STORAGE_ACCESS_KEY=$account_key # Create a VM image based on a storage file -azure vm image create ${image_name} --os linux -l 'West Europe' --blob-url https://${storage_account}.blob.core.windows.net:443/vms/${image_name}.vhd -v +azure vm image create ${image_name} --os linux -l 'West Europe' \ + --blob-url https://${stor_acc}.blob.core.windows.net:443/vms/${image}.vhd -v # Share a file (a vm image for example) with the world: -azure storage blob sas create -a ${storage_account} --container ${container} --blob ${filename} --permissions r +azure storage blob sas create -a ${stor_acc} \ + --container ${container} --blob ${filename} --permissions r # Download a file from a blob storage using curl/wget -# values of the header variables can be calculated like here: https://gist.github.com/jrwren/ff46f4ba177f042ccdc48c080c198f60 +# values of the header variables can be calculated like here: +# https://gist.github.com/jrwren/ff46f4ba177f042ccdc48c080c198f60 curl -v \ -H "$x_ms_date_h" \ -H "$x_ms_version_h" \ diff --git a/sheets/blktrace b/sheets/blktrace index 5b60ab6..a7f5bbc 100644 --- a/sheets/blktrace +++ b/sheets/blktrace @@ -1,5 +1,6 @@ # blktrace -# blktrace is a block layer IO tracing mechanism which provides detailed information about request queue operations up to user space +# A block layer IO tracing mechanism which provides detailed information +# about request queue operations up to user space # trace PC (non-filesystem requests, PC) on the /dev/sdb disk. # blkparse generates human-readable formatting diff --git a/sheets/emacs b/sheets/emacs index cf94aee..15ca752 100644 --- a/sheets/emacs +++ b/sheets/emacs @@ -180,7 +180,8 @@ collapses function definitions in a file to a mere {...} M-x show-subtree If you are in one of the collapsed functions, this un-collapses it -# In order to achieve some of the feats coming up now you have to run etags *.c *.h *.cpp +# In order to achieve some of the feats coming up, +# now you have to run etags *.c *.h *.cpp # (or what ever ending you source files have) in the source directory M-. (Meta dot) If you are in a function call, this will take you to it\'s definition M-x tags-search ENTER diff --git a/sheets/exim b/sheets/exim index 3f7e3da..21298f6 100644 --- a/sheets/exim +++ b/sheets/exim @@ -22,7 +22,8 @@ exiqgrep -f [user]@domain # Search the queue for messages from a specific recipient exiqgrep -r [user]@domain -# Print messages older than the specified number of seconds (1 day = 86400 seconds) +# Print messages older than the specified number of seconds +# (1 day = 86400 seconds) exiqgrep -o 86400 # Print messages younger than the specified number of seconds @@ -40,7 +41,8 @@ exim -Mf [ ... ] # Thaw (unfreeze) a message exim -Mt [ ... ] -# Deliver message, whether it's frozen or not, whether the retry time has been reached or not +# Deliver message, whether it's frozen or not, +# whether the retry time has been reached or not exim -M [ ... ] # Force message to fail and bounce as "cancelled by administrator" diff --git a/sheets/go b/sheets/go index 8357857..008acaa 100644 --- a/sheets/go +++ b/sheets/go @@ -1,4 +1,5 @@ -# Go is a free and open source programming language created at Google +# Go +# A free and open source programming language created at Google # and go is a tool for managing go source code. # Download and install a package, specified by its import path: @@ -10,7 +11,8 @@ go run file.go # Compile the package present in the current directory: go build -# Execute all test cases of the current package (files have to end with _test.go): +# Execute all test cases of the current package +# (files have to end with _test.go): go test # Compile and install the current package: diff --git a/sheets/ipython b/sheets/ipython index 888da22..5f72116 100644 --- a/sheets/ipython +++ b/sheets/ipython @@ -1,10 +1,10 @@ -# create a ipython profile +# Create a ipython profile ipython profile create profile_name -# use specified profile +# Use specified profile ipython --profile=${profile_name} -# list objects, functions, etc. that have been added in the current namespace, +# List objects, functions, etc. that have been added in the current namespace, # as well as modules that have been imported %who @@ -12,7 +12,8 @@ ipython --profile=${profile_name} # so that they can be executed all together using the assigned name %macro -# This will open an editor (whatever the shell variable EDITOR is set to, see above, or vi/vim if no variable is set) +# This will open an editor (whatever the shell variable EDITOR is set to, +# see above, or vi/vim if no variable is set) # containing the specified material, based on what arguments are provided, # and will execute that code once the editor is exited %edit @@ -20,23 +21,25 @@ ipython --profile=${profile_name} # This lists all ipython magic commands %lsmagic -# store variables, functions, etc. that you've defined in your .ipython/ipythonrc file for use in future sessions +# Store variables, functions, etc. that you've defined in .ipython/ipythonrc +# for use in future sessions %store -# configure ipython to automatically open the python debugger pdb when an error occurs +# Configure ipython to automatically open the python debugger pdb +# when an error occurs %pdb -# timing functions to see how long expressions take to execute +# Timing functions to see how long expressions take to execute %time %timeit -# to log ipython input and/or output to files +# Log ipython input and/or output to files %logstart %logon %logoff %logstate -# (to change directories, manipulate directory stacks, and create directory "bookmarks") +# Change directories, manipulate directory stacks, create directory "bookmarks" %cd %pushd %popd diff --git a/sheets/jq b/sheets/jq index 8d657cf..f22f080 100644 --- a/sheets/jq +++ b/sheets/jq @@ -8,7 +8,8 @@ jq # (or all key-value pairs from objects) in a JSON file: jq .[] -# Read JSON objects from a file into an array, and output it (inverse of jq .[]): +# Read JSON objects from a file into an array, and output it +# (inverse of jq .[]): jq --slurp # Output the first element in a JSON file: @@ -42,7 +43,8 @@ jq 'map({ a, b })' # => [ { "a": 1, "b": 2 }, ...] # Converting arbitrary data to json -jq -r '(map(keys) | add | unique | sort) as $cols | .[] as $row | $cols | map($row[.]) | @csv' +jq -r '(map(keys) | add | unique | sort) as $cols \ + | .[] as $row | $cols | map($row[.]) | @csv' # # [ { "foo": 1, "bar": 2}, { "foo": 3, "baz": 4}] # @@ -150,4 +152,3 @@ jq '.[] | [.foo, .bar] | @csv' -r # # [{ "foo": 1, "bar": 2, "baz":3 }] # => 1,2 - diff --git a/sheets/nmap b/sheets/nmap index 46c27c0..d59377d 100644 --- a/sheets/nmap +++ b/sheets/nmap @@ -4,8 +4,10 @@ nmap [target] # Scan from a list of targets: nmap -iL [list.txt] -# Scan port for all available A records (useful when multiple A records are returned by the DNS server) -nmap --script resolveall --script-args newtargets,resolveall.hosts=[target] -p [port] +# Scan port for all available A records +# (useful when multiple A records are returned by the DNS server) +nmap --script resolveall \ + --script-args newtargets,resolveall.hosts=[target] -p [port] # iPv6: nmap -6 [target] @@ -49,10 +51,12 @@ nmap -sP 192.168.0.0/24 # Use some script: nmap --script default,safe -# Loads the script in the default category, the banner script, and all .nse files in the directory /home/user/customscripts. +# Loads the script in the default category, the banner script, +# and all .nse files in the directory /home/user/customscripts. nmap --script default,banner,/home/user/customscripts -# Loads all scripts whose name starts with http-, such as http-auth and http-open-proxy. +# Loads all scripts whose name starts with http-, +# such as http-auth and http-open-proxy. nmap --script 'http-*' # Loads every script except for those in the intrusive category. @@ -61,7 +65,8 @@ nmap --script "not intrusive" # Loads those scripts that are in both the default and safe categories. nmap --script "default and safe" -# Loads scripts in the default, safe, or intrusive categories, except for those whose names start with http-. +# Loads scripts in the default, safe, or intrusive categories, +# except for those whose names start with http-. nmap --script "(default or safe or intrusive) and not http-*" # Scan for the heartbleed diff --git a/sheets/perl b/sheets/perl index b612f42..db39170 100644 --- a/sheets/perl +++ b/sheets/perl @@ -16,10 +16,12 @@ perl -Mmodule -e perl_statement # Run a Perl script in debug mode, using perldebug: perl -d script.pl -# Loo[p] over all lines of a file, editing them [i]n-place using a find/replace [e]xpression: +# Loo[p] over all lines of a file, editing them [i]n-place +# using a find/replace [e]xpression perl -p -i -e 's/find/replace/g' filename -# Run a find/replace expression on a file, saving the original file with a given extension: +# Run a find/replace expression on a file, +# saving the original file with a given extension: perl -p -i'.old' -e 's/find/replace/g' filename # See also: diff --git a/sheets/psql b/sheets/psql index 539622b..a5308fd 100644 --- a/sheets/psql +++ b/sheets/psql @@ -1,19 +1,23 @@ # psql # PostgreSQL command-line client. -# Connect to database. It connects to localhost using default port 5432 with default user as currently logged in user: +# Connect to database. +# It connects to localhost using default port 5432 +# with default user as currently logged in user psql database -# Connect to database on given server host running on given port with given username, without a password prompt: +# Connect to database on given server host running on given port +# with given username, without a password prompt psql -h host -p port -U username database -# Connect to database; user will be prompted for password: +# Connect to database; user will be prompted for password psql -h host -p port -U username -W database -# Execute a single SQL query or PostgreSQL command on the given database (useful in shell scripts): +# Execute a single SQL query or PostgreSQL command +# on the given database (useful in shell scripts) psql -c 'query' database -# Execute commands from a file on the given database: +# Execute commands from a file on the given database psql database -f file.sql # See also: diff --git a/sheets/redis b/sheets/redis index bc2544c..a01212e 100644 --- a/sheets/redis +++ b/sheets/redis @@ -1,5 +1,6 @@ # redis -# Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker +# Redis is an open source (BSD licensed), in-memory data structure store, +# used as a database, cache and message broker # connect to redis server (port 6397) nc localhost 6397 diff --git a/sheets/sed b/sheets/sed index 34040a6..43bcd34 100644 --- a/sheets/sed +++ b/sheets/sed @@ -1,14 +1,17 @@ +# sed +# A stream editor. Used to perform basic text transformations + # Preview a file edit, via substitution. -sudo sed 's/Name=Xfce Session/Name=Xfce_Session/' /usr/share/xsessions/xfce.desktop +sudo sed 's/Name=Xfce Session/Name=Xfce_Session/' FILE -# Replace the same string more than once per line (appending g flag), via substitution. -sudo sed 's/Name=Xfce Session/Name=Xfce_Session/g' /usr/share/xsessions/xfce.desktop +# Replace the same string more than once per line (g flag) +sudo sed 's/Name=Xfce Session/Name=Xfce_Session/g' FILE -# Edit a file (adding -i flag), via substitution, in-place; changes are made to the file(s). -sudo sed -i 's/Name=Xfce Session/Name=Xfce_Session/' /usr/share/xsessions/xfce.desktop +# Edit a file (adding -i flag), in-place; changes are made to the file(s). +sudo sed -i 's/Name=Xfce Session/Name=Xfce_Session/' FILE # It can become necessary to escape special characters in your string. -sed -i 's/\/path\/to\/somewhere\//\/path\/to\/anotherplace\//' /tmp/filetoedit +sed -i 's/\/path\/to\/somewhere\//\/path\/to\/anotherplace\//' FILE # Change your sed delimiter to a pipe to avoid escaping slashes. -sed -i 's|/path/to/somewhere/|/path/to/anotherplace/|' /tmp/filetoedit +sed -i 's|/path/to/somewhere/|/path/to/anotherplace/|' FILE diff --git a/sheets/smartctl b/sheets/smartctl index 7a77044..540ea26 100644 --- a/sheets/smartctl +++ b/sheets/smartctl @@ -4,7 +4,7 @@ # Quickly check the overall health of a drive smartctl -H /dev/sda -# Obtain information on the drive: view the type of drive, its serial number, and so forth +# Obtain information on the drive: type of drive, serial number, etc. smartctl -i /dev/sda # initiate short tests for the drive diff --git a/sheets/solidity b/sheets/solidity index 6cff4e3..434d9f7 100644 --- a/sheets/solidity +++ b/sheets/solidity @@ -1,7 +1,9 @@ -# Solidity is a contract-oriented, high-level language for implementing smart contracts. +# Solidity +# A contract-oriented, high-level language for implementing smart contracts. # It is designed to target the Ethereum Virtual Machine (EVM). -# To create a contract, declare which solidity version the source code is written for +# To create a contract, +# declare which solidity version the source code is written for pragma solidity ^0.4.0; # See also: diff --git a/sheets/yq_v4 b/sheets/yq_v4 index 2155659..818d438 100644 --- a/sheets/yq_v4 +++ b/sheets/yq_v4 @@ -7,15 +7,18 @@ yq eval '.spec.template' example.yml # Assign spec.selector.matchLabels to spec.template.metadata.labels -yq eval '.spec.selector.matchLabels |= .spec.template.metadata.labels' example.yaml +yq eval \ + '.spec.selector.matchLabels |= .spec.template.metadata.labels' example.yaml -# Update parent to be the child value. b is a's child. '|=' means the . on the right is relative to the left. +# Update parent to be the child value. b is a's child. +# '|=' means the . on the right is relative to the left. yq eval '.a |= .b' sample.yml # Update multiple nodes. a and c are siblings. yq eval '(.a, .c) |= "potatoe"' sample.yml -# Update selected results. Only update a's children with value=='apple' to 'frog'. +# Update selected results. +# Only update a's children with value=='apple' to 'frog'. yq eval '.a[] | select(. == "apple") |= "frog"' sample.yml # Match with boolean operator 'or'.