Last active
November 13, 2022 21:37
-
-
Save 5t33/49e66bdb98a927d8d433fcedf3608c05 to your computer and use it in GitHub Desktop.
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
ps -daf # show me all the processes and all the info | |
ps aux # show me processes as well, but more organized | |
lsof -i :<port> # get PID and other info of process running on port | |
# Below is an example of some things you can do with gawk/awk (gawk on mac). Read man for more detail. | |
some_command | gawk/awk '{variable = gensub(/<your regex>/,"\\1","g",$1); if(!d[ip]) { print variable; d[ip]=1; fflush(stdout)}' | |
#another awk example that I don't fully understand, but keeping it to look into later | |
some_command | awk '$1>1024 {print ":" $0; fflush()}' | |
#tcp dump with conditions & some helpful options | |
tcpdump -nn -q ip -l and 'dst port 8200 or dst port 8299 or dst port 80 or dst port 443' | |
# use the output of a command as an input to another with xargs | |
some_command | xargs some_command | |
# use the output of a command as an input to another with xargs, and only use the first column/output | |
some_command | xargs -n1 some_command | |
du -H # what's gunking up the current folder path | |
df # what's gunking up file system | |
sudo netstat -tulpn | grep LISTEN # What's listening -t == tcp, -u == udp, -l show listening, -p show PID, -n Don't resolve names | |
sudo journalctl -u service-name.service # see log output from service --since and --until can be used for dates | |
sudo journalctl -xefu service-name | |
lsblk # List blocks | |
# https://access.redhat.com/solutions/5540131 | |
sudo growpart <disc> 1 # grows a partition (in this case 1) to fill out the rest of the disk | |
rpm -qa| grep -i growpart # Verify growpart package is installed, If not then install | |
yum install cloud-utils-growpart -y | |
# Verify the partition table using the below command before running growpart | |
parted <disc> u s p | |
lvextend +100%PVS <logical volume path> <physical volume path> | |
sudo service <service> restart | |
systemctl service restart | |
[ -z "$PROFILE" ] && echo "var exists" # check for variable | |
[ -z "$FILE" ] && echo "var exists" # check for file | |
[ -z "$DIR" ] && echo "var exists" # check for dir | |
arr=["a","b","c"]; if [[ "${arr[@]}" =~ "${DIR}," ]]; then echo "$DIR is in array"; fi # check that value is in array | |
# write multiple lines to a file | |
cat > ./file_name.ext <<EOL | |
file content | |
more content | |
EOL | |
# CLI input | |
while test $# -gt 0; do | |
case "$1" in | |
--var|-v) | |
shift | |
VAR=$1 | |
shift | |
;; | |
*) | |
echo "$1 is not a recognized flag!" | |
usage | |
exit 1; | |
;; | |
esac | |
done | |
IFS=',' read -r -a array <<< "$string" # split string | |
IFS=$'\n' read -rd '' -a ids <<< "$string" # split string new line | |
#loop through array | |
for val in "${arr[@]}"; | |
do | |
echo $val | |
done | |
#function call | |
func () { | |
echo "Arg 1: $1" | |
} | |
func "first argument" | |
ENV_VAR=$FENV_VAR envsubst < template.json > outfile.json #substitute values in a file | |
trap 'printf "\n"' DEBUG # Adds a blank line between any output on the screen. | |
export PS1="\n[\u@\h \W] $ " # change PS1 variable to include user & IP | |
# print with colors" | |
usage() { | |
printf "usage:\\n\033[32m./run_change.sh -profile msysmc -region us-west-2 -service customer-alerts -cluster ecs51v-usw2-stg -new_cluster ecs52v-usw2-stg -build_project customer-alerts-api-deploy-stg\033[0m\\n" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment