- Bash cheatsheet
- Helpful links
- Tricks & tips
- Wait until something works
- tr
- Check udp port
- Check for argument
- Cat content to file
- Using journalctl & sytemctl
- Compress folder while excluding certain files
- Datadog troubleshoot
- [Generate markdown table from @so0k link](#generate-markdown-table-from-so0k-linkhttpsgistgithubcomso0k256cde434cbb0b58702249b31203a357)
- 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
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:]'
: remove all spaces
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