General notes that I may need in future and I don’t know where to put them in Notes.app 📝
Shell Commands
ZSH (oh-my-zsh)
- cd to history
dirs -v cd -<TAB>
SSH
- show ssh key fingerprint:
ssh-keygen -lf .ssh/id_rsa.pub
- generate keys:
ssh-keygen -f ~/keyfile -t ecdsa -b 521
SHELL/BASH
- add prefix to the beginning of a line
# If you want to edit the file in-place sed -i -e 's/^/prefix/' file # If you want to create a new file sed -e 's/^/prefix/' file > file.new
- read file by line
while IFS= read -r line do # script done < file.txt
- grep and display only requested string/regex
grep -Po 'Your support ID is: [0-9]+'
- run a simple http server
python3 -m http.server --cgi 8080
- convert encoding
iconv --list iconv -f CP1250 -t UTF-8 Movie.srt > Movie.utf8.srt
Makefile
- basic syntax:
build: <TAB>command <EMPTY LINE>
- Check whether the TAB are correctly set:
cat -e -t -v makefile_name
VIM
- Integrate with system clipboard:
- copy selected part: visually select text(type v or V in normal mode) and type
:w !pbcopy
- copy the whole file
:%w !pbcopy
- paste from the clipboard
:r !pbpaste
- copy selected part: visually select text(type v or V in normal mode) and type
cURL
- Resolve a hostname to custom IP:
curl --resolve lubos.klokner.sk:443:127.0.0.1 https://lubos.klokner.sk/
- Do not check the certificate:
curl -k https://lubos.klokner.sk/
- Read data from a file:
# file.txt: param1=value1¶m2=value2 curl -G 'http://example.com/' -d @file.txt curl -G 'http://example.com/' --data-urlencode @file.txt
- Send Cookie:
curl -b 'flag6=COOKIE_VALUE8; expires=Mon, 2 Aug 2021 20:20:20 UTC; path=/' https://lubos.klokner.sk/
VSCODE
- Multi-Line editing: + fn + f2
- Duplicate lines of code in both directions: shift + alt + arrow up/down
- Move line: alt + arrow up/down
- Comment: + /
macOS
VMware Fusion
- Fix networking issues:
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
Networking
- Allow packet forwarding:
sudo sysctl -w net.inet.ip.forwarding=1
tcpdump
- grep in the network stream:
sudo tcpdump -A -l dst port 80 | grep "^Cookie:"
Docker
Markup Cheat Sheet
F5 BIG-IP
- tcpdump:
tcpdump -vvv -nni 0.0:nnn "(host [client_ip] and host [VS_ip]) or host [pool_member_ip]" -s0 -w /var/tmp/case_description.pcap
- license from CLI:
get_dossier -b "base key" -a "actkey1,actkey2" # goto -> https://activate.f5.com & paste the dossier here # copy the license from the webpage cat - > /config/bigip.license # CTRL + D reloadlic
- reset to factory defaults (v13.0+):
tmsh load /sys config default tmsh save /sys config partitions all