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
pull/143/head
Igor Chubin 4 years ago
parent a4b941e5b8
commit 0adbf03348

@ -1,5 +1,6 @@
# MegaCli introduced by LSI as a command line administration of LSI MegaRaid controllers. # MegaCli
# With megacli we can create physical raids, gather info about raids and monitor raids. # A command line administration of LSI MegaRaid controllers.
# It allows to create physical raids, gather info about raids and monitor raids.
# Install MegaCLI # Install MegaCLI
yum install MegaCli # CentOS yum install MegaCli # CentOS
@ -21,4 +22,3 @@ MegaCli -PDInfo -PhysDrv [E:S] -aALL
# Battery backup information # Battery backup information
MegaCli -AdpBbuCmd -aALL MegaCli -AdpBbuCmd -aALL

@ -4,11 +4,14 @@
# Install Azure CLI 2.0 with one curl command. # Install Azure CLI 2.0 with one curl command.
curl -L https://aka.ms/InstallAzureCli | bash curl -L https://aka.ms/InstallAzureCli | bash
# create a resource group named "MyResourceGroup" in the westus2 region of Azure # create a resource group named "MyRG" in the 'westus2' region
az group create -n MyResourceGroup -l westus2 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 # create a Linux VM using the UbuntuTLS image,
az vm create -n MyLinuxVM -g MyResourceGroup --ssh-key-value $HOME/.ssh/id_rsa.pub --image UbuntuLTS --data-disk-sizes-gb 10 20 # 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 # list VMs
az vm list --output table az vm list --output table
@ -16,28 +19,28 @@ az vm list --output table
# list only VMs having distinct state # list only VMs having distinct state
az vm list -d --query "[?powerState=='VM running']" --output table az vm list -d --query "[?powerState=='VM running']" --output table
# delete VM (with the name MyLinuxVM in the group MyResourceGroup) # delete VM (with the name MyLinuxVM in the group MyRG)
az vm delete -g MyResourceGroup -n MyLinuxVM --yes az vm delete -g MyRG -n MyLinuxVM --yes
# Delete all VMs in a resource group # 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 # Create an Image based on a running VM
az vm deallocate -g MyResourceGroup -n MyLinuxVM az vm deallocate -g MyRG -n MyLinuxVM
az vm generalize -g MyResourceGroup -n MyLinuxVM az vm generalize -g MyRG -n MyLinuxVM
az image create --resource-group MyResourceGroup --name MyTestImage --source MyLinuxVM az image create --resource-group MyRG --name MyTestImage --source MyLinuxVM
# Running VM based on a VHD # Running VM based on a VHD
az storage blob upload --account-name "${account_name}" \ az storage blob upload --account-name "${account_name}" \
--account-key "${account_key}" --container-name "${container_name}" --type page \ --account-key "${account_key}" --container-name "${container}" --type page \
--file "${file}" --name "${vhd_name}" --file "${file}" --name "${vhd}"
az disk create \ az disk create \
--resource-group ${resource_group} \ --resource-group "${resource_group}" \
--name myManagedDisk \ --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 # 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 # Show storage accounts
az storage account list --output table 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 az storage container list --account-name mystorageaccount --output table
# Show blobs in a container # 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 # list account keys
az storage account keys list --account-name STORAGE_NAME --resource-group RESOURCE_GROUP az storage account keys list --account-name STORAGE_NAME --resource-group RESOURCE_GROUP
@ -62,8 +66,8 @@ az disk list --output table
# Copy blob # Copy blob
az storage blob copy start \ 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' \ --source-uri 'https://xxx.blob.core.windows.net/jzwuuuzzapn0/abcd?...' \
--account-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX== \ --account-key XXXXXXXXXX== \
--account-name destaccount \ --account-name destaccount \
--destination-container vms \ --destination-container vms \
--destination-blob DESTINATION-blob.vhd --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 az snapshot create --resource-group IC-EXASOL-001 --source vm1-disk1 -n vm1-snap1
# create SAS url for a snapshot # 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 # attach disk
az vm disk attach --vm-name vm1 -g RESOURCE_GROUP --disk DISK1_ID az vm disk attach --vm-name vm1 -g RESOURCE_GROUP --disk DISK1_ID

@ -10,13 +10,14 @@ azure login
azure login -u <your organizational ID email address> azure login -u <your organizational ID email address>
# This will login in using a service principal # This will login in using a service principal
azure login -u "<service-principal-id>" -p "<key>" --service-principal --tenant "<tenant-id>" azure login -u "<principal>" -p "<key>" --service-principal --tenant "<tenant>"
# find images with Linux in name # find images with Linux in name
azure vm image list | grep "Linux" azure vm image list | grep "Linux"
# start a new VM (in asm mode) # 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 # List VMs disks
azure vm disk list azure vm disk list
@ -24,24 +25,28 @@ azure vm disk list
# Remove all disks of VMs labeled with LABEL # Remove all disks of VMs labeled with LABEL
for disk in $(azure vm disk list | grep LABEL | awk '{print $2}') for disk in $(azure vm disk list | grep LABEL | awk '{print $2}')
do do
azure vm disk delete --blob-delete "$disk" azure vm disk delete --blob-delete "$disk"
done done
# Create storage account $myacct in location 'West US' # 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 # Set default account environment variables
export AZURE_STORAGE_ACCOUNT=$account_name export AZURE_STORAGE_ACCOUNT=$account_name
export AZURE_STORAGE_ACCESS_KEY=$account_key export AZURE_STORAGE_ACCESS_KEY=$account_key
# Create a VM image based on a storage file # 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: # 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 # 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 \ curl -v \
-H "$x_ms_date_h" \ -H "$x_ms_date_h" \
-H "$x_ms_version_h" \ -H "$x_ms_version_h" \

@ -1,5 +1,6 @@
# blktrace # 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. # trace PC (non-filesystem requests, PC) on the /dev/sdb disk.
# blkparse generates human-readable formatting # blkparse generates human-readable formatting

@ -180,7 +180,8 @@
collapses function definitions in a file to a mere {...} collapses function definitions in a file to a mere {...}
M-x show-subtree M-x show-subtree
If you are in one of the collapsed functions, this un-collapses it 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 # (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-. (Meta dot) If you are in a function call, this will take you to it\'s definition
M-x tags-search ENTER M-x tags-search ENTER

@ -22,7 +22,8 @@ exiqgrep -f [user]@domain
# Search the queue for messages from a specific recipient # Search the queue for messages from a specific recipient
exiqgrep -r [user]@domain 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 exiqgrep -o 86400
# Print messages younger than the specified number of seconds # Print messages younger than the specified number of seconds
@ -40,7 +41,8 @@ exim -Mf <message-id> [ <message-id> ... ]
# Thaw (unfreeze) a message # Thaw (unfreeze) a message
exim -Mt <message-id> [ <message-id> ... ] exim -Mt <message-id> [ <message-id> ... ]
# 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 <message-id> [ <message-id> ... ] exim -M <message-id> [ <message-id> ... ]
# Force message to fail and bounce as "cancelled by administrator" # Force message to fail and bounce as "cancelled by administrator"

@ -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. # and go is a tool for managing go source code.
# Download and install a package, specified by its import path: # 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: # Compile the package present in the current directory:
go build 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 go test
# Compile and install the current package: # Compile and install the current package:

@ -1,10 +1,10 @@
# create a ipython profile # Create a ipython profile
ipython profile create profile_name ipython profile create profile_name
# use specified profile # Use specified profile
ipython --profile=${profile_name} 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 # as well as modules that have been imported
%who %who
@ -12,7 +12,8 @@ ipython --profile=${profile_name}
# so that they can be executed all together using the assigned name # so that they can be executed all together using the assigned name
%macro %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, # containing the specified material, based on what arguments are provided,
# and will execute that code once the editor is exited # and will execute that code once the editor is exited
%edit %edit
@ -20,23 +21,25 @@ ipython --profile=${profile_name}
# This lists all ipython magic commands # This lists all ipython magic commands
%lsmagic %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 %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 %pdb
# timing functions to see how long expressions take to execute # Timing functions to see how long expressions take to execute
%time %time
%timeit %timeit
# to log ipython input and/or output to files # Log ipython input and/or output to files
%logstart %logstart
%logon %logon
%logoff %logoff
%logstate %logstate
# (to change directories, manipulate directory stacks, and create directory "bookmarks") # Change directories, manipulate directory stacks, create directory "bookmarks"
%cd %cd
%pushd %pushd
%popd %popd

@ -8,7 +8,8 @@ jq
# (or all key-value pairs from objects) in a JSON file: # (or all key-value pairs from objects) in a JSON file:
jq .[] 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 jq --slurp
# Output the first element in a JSON file: # Output the first element in a JSON file:
@ -42,7 +43,8 @@ jq 'map({ a, b })'
# => [ { "a": 1, "b": 2 }, ...] # => [ { "a": 1, "b": 2 }, ...]
# Converting arbitrary data to json # 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}] # [ { "foo": 1, "bar": 2}, { "foo": 3, "baz": 4}]
# #
@ -150,4 +152,3 @@ jq '.[] | [.foo, .bar] | @csv' -r
# #
# [{ "foo": 1, "bar": 2, "baz":3 }] # [{ "foo": 1, "bar": 2, "baz":3 }]
# => 1,2 # => 1,2

@ -4,8 +4,10 @@ nmap [target]
# Scan from a list of targets: # Scan from a list of targets:
nmap -iL [list.txt] nmap -iL [list.txt]
# Scan port for all available A records (useful when multiple A records are returned by the DNS server) # Scan port for all available A records
nmap --script resolveall --script-args newtargets,resolveall.hosts=[target] -p [port] # (useful when multiple A records are returned by the DNS server)
nmap --script resolveall \
--script-args newtargets,resolveall.hosts=[target] -p [port]
# iPv6: # iPv6:
nmap -6 [target] nmap -6 [target]
@ -49,10 +51,12 @@ nmap -sP 192.168.0.0/24
# Use some script: # Use some script:
nmap --script default,safe 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 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-*' nmap --script 'http-*'
# Loads every script except for those in the intrusive category. # 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. # Loads those scripts that are in both the default and safe categories.
nmap --script "default and safe" 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-*" nmap --script "(default or safe or intrusive) and not http-*"
# Scan for the heartbleed # Scan for the heartbleed

@ -16,10 +16,12 @@ perl -Mmodule -e perl_statement
# Run a Perl script in debug mode, using perldebug: # Run a Perl script in debug mode, using perldebug:
perl -d script.pl 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 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 perl -p -i'.old' -e 's/find/replace/g' filename
# See also: # See also:

@ -1,19 +1,23 @@
# psql # psql
# PostgreSQL command-line client. # 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 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 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 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 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 psql database -f file.sql
# See also: # See also:

@ -1,5 +1,6 @@
# redis # 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) # connect to redis server (port 6397)
nc localhost 6397 nc localhost 6397

@ -1,14 +1,17 @@
# sed
# A stream editor. Used to perform basic text transformations
# Preview a file edit, via substitution. # 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. # Replace the same string more than once per line (g flag)
sudo sed 's/Name=Xfce Session/Name=Xfce_Session/g' /usr/share/xsessions/xfce.desktop 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). # 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/' /usr/share/xsessions/xfce.desktop sudo sed -i 's/Name=Xfce Session/Name=Xfce_Session/' FILE
# It can become necessary to escape special characters in your string. # 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. # 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

@ -4,7 +4,7 @@
# Quickly check the overall health of a drive # Quickly check the overall health of a drive
smartctl -H /dev/sda 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 smartctl -i /dev/sda
# initiate short tests for the drive # initiate short tests for the drive

@ -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). # 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; pragma solidity ^0.4.0;
# See also: # See also:

@ -7,15 +7,18 @@
yq eval '.spec.template' example.yml yq eval '.spec.template' example.yml
# Assign spec.selector.matchLabels to spec.template.metadata.labels # 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 yq eval '.a |= .b' sample.yml
# Update multiple nodes. a and c are siblings. # Update multiple nodes. a and c are siblings.
yq eval '(.a, .c) |= "potatoe"' sample.yml 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 yq eval '.a[] | select(. == "apple") |= "frog"' sample.yml
# Match with boolean operator 'or'. # Match with boolean operator 'or'.

Loading…
Cancel
Save