This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This captures VRRP packet by tshark | |
tshark -nni enp0s3 -f 'vrrp' | |
# This also captures VRRP packet by tcpdump | |
# <interface> <how many packets> <verbose - v or vv> <filter> | |
# -i $NIC -c ${NUM} -v ${...EXPRESSIONS} | |
tcpdump -i enp0s3 -c 100 -v vrrp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ref: https://mirwebma.tistory.com/112 | |
# See all users | |
grep ${USERNAME} /etc/passwd | |
# Add user | |
adduser ${USERNAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ref: https://stackoverflow.com/a/15429426 | |
read -d '' sql << EOF | |
select c1, c2 from foo | |
where c1='something' | |
EOF | |
echo "$sql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SAMPLE="SaMpLe" | |
echo ${SAMPLE^^} # This makes the string to be uppercase -> STDOUT("SAMPLE") | |
echo ${SAMPLE,,} # This makes the string to be lowercase -> STDOUT("sample") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git pull # This refeshes the local branches to fetch remote branches | |
git checkout origin/${BRANCH_NAME} # I donno if this necessary | |
git switch -c ${BRANCH_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ref: https://stackoverflow.com/q/2003505 | |
# Ref: https://stackoverflow.com/a/2003515 | |
# Delete local-cached remote branch | |
git branch -rd origin/${BRANCH} | |
# Delete local branch | |
git branch -D ${BRANCH} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ip -4 addr show enp0s3 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ref: https://linuxize.com/post/how-to-compare-strings-in-bash/ | |
# Basic | |
[[ "string1" == "string2" ]] && echo "Equal" || echo "Not equal" | |
# Variable alloc | |
TEMP=$([[ "string1" == "string2" ]] && echo "Equal" || echo "Not equal") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo cut -d: -f1 /etc/passwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# systemd cgroup ls | |
sudo systemd-cgls |