Rsync
$ rsync -avzhe 'ssh -p [port_number]' -P [user@remote_ip]:/path/to/file/source /path/to/file/destination
Scan IP on Network
$ nmap -sP [ip_address/prefix]
Search Available Version of Spesific Package on Debian Based OS
$ apt list -a <package_name>
Install Spesific Kubernetes Version
$ sudo apt update;sudo apt install -qy kubelet=1.15.5-00 kubectl=1.15.5-00 kubeadm=1.15.5-00
Open Spesific Port on Centos 7
iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 9100 -j ACCEPT
Replace String Using Sed
sed -i 's/old-string/new-string/g'
Find and copy files
find /var/cache/dnf -iname "*.rpm" -exec cp {} packages/ \;
Encrypt secret envar value using Google KMS
echo -n "This is my secret" | gcloud kms encrypt --plaintext-file=- --ciphertext-file=- --location=global --keyring=mykeyring --key=myappkey | base64 -w 0
Encrypt file using Google KMS
gcloud kms encrypt \
--key myappkey \
--keyring mykeyring \
--location global \
--plaintext-file application.properties \
--ciphertext-file application.properties.enc
Check DNS record
$ dig +noall +answer google.com
google.com. 204 IN A 74.125.24.102
google.com. 204 IN A 74.125.24.138
google.com. 204 IN A 74.125.24.139
google.com. 204 IN A 74.125.24.101
google.com. 204 IN A 74.125.24.100
google.com. 204 IN A 74.125.24.113
Check service port
$ getent services 53
domain 53/tcp
Troubleshoot SELinux Issue on RHEL/CentOS
# 1. Find your error from journalctl or audit.log then get the audit ID.
# 2. Analyze
grep 1624284378.419:2066 /var/log/audit/audit.log |audit2why
Replace multiple file on OSX
find /to/my/path -type f -name "*.yaml" -exec sed -i '' -e 's/halo.com/hai.id/g' {} \;
Generate Kubernetes secret and configmap YAML manifest
# Secret
kubectl create secret generic my-config --from-file=configuration/ -o yaml --dry-run
# Configmap
kubectl create configmap my-config --from-file=configuration/ -o yaml --dry-run
Generate docker credential secret for Kubernetes
kubectl create -n registry secret docker-registry registry-auth-dockerconfig-secret --docker-server=registry.rahmatawe.com --docker-username=[YOUR_USERNAME] --docker-password=[YOUR_REGISTRY_PASSWORD] --dry-run=client -oyaml
Running short-lived container to compile source code
$ sudo docker run --rm -it -v ${PWD}:/app -w /app openjdk:11-jdk-slim /bin/sh -c ./gradlew buildRun