ab

Send 10,000 requests, using 10 sockets at a time: ab -n 10000 -c 10 https://10.10.10.10/ Send requests with a BIG-IP persistence cookie: ab -n 10000 -C BIGipServerMyPool=1677787402.36895.0000 http://10.10.10.10/

bash

Miscellaneous: Run script with verbose output: bash -v Check for syntax errors: bash -n Show xtrace info: bash -x Lines which start with + are executed in the shell Lines which start with ++ are executed in a sub-shell Loop over alphabet with upper and lower case: for l in {{A..Z},{a..z}}; do echo $l ; done Print text in beautiful columns by piping to: column -t Keyboard shortcuts: If you’re using iTerm2, these may not work unless you follow these steps....

curl

Display response code and total time: curl -s -w "%{http_code} - %{time_total}\n" -o /dev/null www.jamessimas.com curl multiple IPs with one command: curl 10.20.20.8[0-9]:80/ Overriding DNS: curl --resolve "www.jamessimas.com:80/10.11.12.13" www.jamessimas.com

cut

Delimited: The delimiter in the below examples is :. Show field 1: cut -f 1 -d : /etc/password Show field 2 and sort results numerically: cut -f 2 -d : /etc/password | sort -n Show all fields after field 1: cut -d: -f 2: Show fields 1 through 2: cut -d : -f1-2 Miscellaneous: Cut 10 from start of line: cut -c -10

dig

Display short response: dig +short www.google.com Display only answer section: dig +noall +answer www.google.com Specify source address for query: dig -b <source address[:#port]> Specify DNS server to query: dig @DNS_SERVER www.google.com Use ends0: dig @DNS_SERVER +subnet=10.11.12.13 1.1.1.1

git

Branching and Checkout: Clean up local banches: git remote prune --dry-run origin git remote prune origin Update local branch without it being checked out: git fetch origin src_branch:local_branch Show which remote branch local branches are tracking: git branch -vv Display branches by last commit date: git for-each-ref --sort=-committerdate refs/heads/ Copy files/directories from another branch to current branch: git checkout source_branch -- path/to/dir/ path/to/file.txt Reset to a particular commit without losing changes: Reset to one commit past most recent: git reset HEAD^ Reset to particular commit: git reset COMMIT_ID Diffing branches:...

golang

go doc Display doc for current package: go doc Display doc for type in current package: go doc TYPE or go doc -all TYPE go test Run all tests: Run all tests: go test ./... Run all tests in package: go test modulename/pkg/packagename/ Run all tests in file: go test path/to/file_test.go Run subset of tests: Run function tests: go test path/to/file_test.go -run FUNCTION_TEST_NAME Run a single test in function tests: go test path/to/file_test....

sort

Numericaly sort file. Fields are separated by :. Use key in position 2: sort -n -k2 -t : /etc/password Sort by size of directories/files: du -h | sort -n

tarsnap

List archives: tarsnap --list-archives | sort List size of all archives: tarsnap --print-stats Create archive: tarsnap -v -c -f ARCHIVE_NAME /path/to/file /path/to/dir Restore archive: tarsnap -v -x -f ARCHIVE_NAME Delete archive: tarsnap -d -f ARCHIVE_NAME Useful doc: https://www.tarsnap.com/simple-usage.html

Time Machine

Speed up backups: sudo sysctl debug.lowpri_throttle_enabled=0 Normal speed backups: sudo sysctl debug.lowpri_throttle_enabled=1