- Bash cheatsheet
- Helpful links
- Kafka
- Tricks & tips
- Terminal Movement
- Print Custom Format
- Validate SSL certificate
- Wait until something works
- tr
- nc
- Check for argument
- Cat content to file
- Using journalctl & sytemctl
- Compress folder while excluding certain files
- Datadog troubleshoot
- Generate markdown table from @so0k link
- Ssh through jumphost
- Set -e
- Ssh issue
- List all processes from pods list
-
tmux cheatsheet link
-
bash cheatsheet link
-
Makefile cheatsheet link
-
GPG cheatsheet link
-
Exit code link
Continuously produce kafka messages
for x in {1..100}; do echo $x; sleep 2;done | kafka-console-producer.sh --bootstrap-server <endpoint> --topic <topic-name>
See: alacritty/alacritty#93 https://www.tecmint.com/linux-command-line-bash-shortcut-keys/
- Ctrl + a: move to beginning
- Ctrl + r: move to end
- Alt(Esc) + b: move backward 1 word
- Alt(Esc) + f: move forward 1 word
- Alt(Esc) + delete: delete backward 1 word
- Alt(Esc) + d: delete forward 1 word
- Ctrl + u: delete from cursor to beginning
- Ctrl + k: delete from cursor to end
Reference: https://stackoverflow.com/a/22625150
curl -w "@curl-format.txt" -o /dev/null -s "http://wordpress.com/"
## curl-format.txt
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n
curl --insecure -v https://google.com 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'
until ping -c 1 mongo; do
echo "waiting for DNS mongo..."
sleep 2
done
tr -s '[[:space:]]' '\n'
: replace space with newline
td -d '[:space:]'
or tr -d " "
: remove all spaces
- Test connection
nc -v -z -w 3 <ip> <port> &> /dev/null && echo "Online" || echo "Offline"
* Check UDP port
```bash
nc -zuv 192.168.0.10 123
if [ -z "$1" ];then
echo "Usage: ./create-users.sh <user-name>"
exit 0
fi
cat > outfile.txt <<EOF
some text
to save
EOF
# display last line
journalctl -b -1 -e
# follow log stream
journalctl -u <service> -f
# restart service
systemctl restart <service>
tar -zcvf file.tar.gz --exclude=".git/*" --exclude="*.zip" .
To display information about the Agent's state with this command.
debian:
docker exec dd-agent service datadog-agent info
alpine:
docker exec dd-agent /opt/datadog-agent/bin/agent info
Generate markdown table from @so0k link
import yaml
print_format="| {parameter:<40}| | {default:<50}|"
def walk_dict(d,keys=[],depth=0):
for k,v in sorted(d.items(),key=lambda x: x[0]):
keys.append(k)
if isinstance(v,dict):
walk_dict(v,keys,depth+1)
else:
print(print_format.format(parameter='`{0}`'.format(".".join(keys)),default='`{0}`'.format(v)))
keys.pop()
s = open("./values.yaml")
d = yaml.load(s)
walk_dict(d)
ssh -o ProxyCommand='ssh <jump_host> nc %h %p' user@host
set -e
stops the execution of a script if a command or pipeline has an error - which is the opposite of the default shell behaviour, which is to ignore errors in scripts. Type help set in a terminal to see the documentation for this built-in command.
ln -s ../Cellar/[email protected]/1.1.0f /usr/local/opt/[email protected]
export NODE_NAME=<NODE_NAME> && export IFS=$'\n' && \
for i in $(kubectl get pod --all-namespaces -o wide | grep $NODE_NAME | awk '{print "kubectl exec -it -n "$1" "$2" -- sh -c \"hostname && ps aux\""}'); \
do bash -c "$i";done