Giter Site home page Giter Site logo

terminal-cheatsheet's Introduction

🚀John's awesome zsh with examples

ZSH

  1. Edit my alias file
 vim $ZSH_CUSTOM/aliases.zsh 

SSH

  1. SSH
ssh -i private-key.pem [email protected] 
  1. Copy file from remote SSH to local
scp -i private-key.pem [email protected]:server.log /Desktop/dev
  1. Copy SSH pub key
pbcopy < ~/.ssh/id_rsa.pub

Linux / Unix

  1. Restart service (NGINX example)
service nginx start
service nginx stop
service nginx reload
  1. Kill process by port
kill $(lsof -t -i:4000) 
  1. Default dir
cd /etc/nginx

Debian

  1. apt update and installation
sudo apt update
sudo apt install git

Docker

  1. Build Docker image and assign tag to $IMAGE_ID
IMAGE_ID=$(docker build -t go-socket-io . -q)
  1. Tag Docker Image with variable $IMAGE_ID
docker tag "$IMAGE_ID" xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/go-socket-io
  1. Push Docker image
docker push xxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/go-socket-io
  1. Remove dangling images
docker image prune
  1. Remove image
docker image rm zenbot_server --force // force
  1. Build image with args
docker build --build-arg SSH_PRIVATE_KEY="$(cat ./bucket_privatekey)" --build-arg SSH_PUBLIC_KEY="$(cat ./bucket_pubkey)" -t go-socket-io .
  1. Run an image with ENV variables; port forward
docker run --rm -p 3000:3000 -e "RAILS_ENV=staging" my-rails-app:latest
  1. Start and SSH into the container, good for debug and develop Dockerfile
docker start -a -i 912176b700a38fb0eaadee778f217030e4acf23066688c8d262d71a5d834b9e0

Vault

https://www.vaultproject.io/docs/commands

Kubernetes

Note: I use k as an alias of kubectl

  1. List all pods in the namespace, with more details (thanks ❤️ @chhetripradeep)
k get pods -o wide --namespace staging
k get pods -o wide --all-namespaces
  1. Delete resources from config yaml
k delete -f deployment.yaml
  1. Delete pods by label k8s-app
k delete pods -l k8s-app=go-socket-io --namespace staging      
  1. Get ELB host of a service
export ELB=$(kubectl get svc -n grafana grafana -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo "http://$ELB"
  1. AWS EKS secret
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')
  1. AWS EKS aws-auth configmap
kubectl -n kube-system describe configmap aws-auth
  1. Get log of a Pod
# Log
k logs pod-a7x0gafg --namespace staging

# Tail the log and grep
k logs --follow ghost-proxy-5496664987-qmbvh --namespace prod | grep 'chicken'

Spinnaker

  1. For anyone that wants to have the old spinnaker capabilities back (basically, being able to rollback a deployment from the UI), we can use a little hack. Go to your browsers console, and set:
window.spinnakerSettings.kubernetesAdHocInfraWritesEnabled = true;

AWS

  1. Named Profile
export AWS_PROFILE=johnhandsome // custom profile
export AWS_PROFILE=default // default profile
  1. Config kubectl profile
aws eks update-kubeconfig --name xxx-cluster-v2

GCP

  1. Config kubectl profile
gcloud container clusters get-credentials qa-cluster-2 --zone=asia-southeast1

GCP Bucket

  1. Upload files to a Bucket Folder
gsutil cp ./build/main.js gs://cdn/dir/
  1. Add allUsers (public Internet) access to a file
gsutil acl ch -u AllUsers:R gs://cdn/dir/main.js
  1. Add metadata to a Bucket file
gsutil setmeta -h "cache-control:max-age=0" gs://cdn/dir/main.js
// gsutil setmeta -h "METADATA_KEY:METADATA_VALUE" gs://BUCKET_NAME/OBJECT_NAME
  1. Get stats of a Bucket file
gsutil stat gs://BUCKET_NAME/OBJECT_NAME

Helm

  1. Start Helm client
export HELM_HOST=:44134 
helm init --client-only             

Tiller Server

export TILLER_NAMESPACE=tiller 
tiller -listen=localhost:44134 -storage=secret -logtostderr

Utils

  1. Tail log real-time
tail -f output.log

NPM / YARN

  1. Upgrade Yarn
npm upgrade --global yarn 
  1. See why dependency exists
yarn why <package>

MongoDB

  1. Connection URI
mongodb://<username>:<password>@<hosts>:<port>/<database>?authSource=<authDatabase>
  1. Aggregate Query:
db.getCollection('customerjourneys').aggregate(
    [{
        $group : {
            _id : { month: { $month: "$createdAt" }, day: { $dayOfMonth: "$createdAt" }, year: { $year: "$createdAt" } },
            dailyEvents: { $sum: 1 }
                }
            }
    ] )

SDKMan

  1. List SDKs
sdk list java
  1. Install SDKs
sdk install java 8.0.252.hs-adpt

Flutter

  1. Switch Flutter version:
flutter channel <env>
  1. Build Android
flutter bundle
  1. Build iOS (Release & No Codesign)
flutter build ios --release --no-codesign
  1. Flutter Upgrade
flutter upgrade
  1. Flutter Clean
flutter clean
  1. Flutter Run
flutter run -d <deviceId>
  1. Flutter Code Gen - build part file (w/o deletion of existing files)
flutter pub run build_runner build
flutter packages pub run build_runner watch --delete-conflicting-outputs
  1. Flutter Code Gen - translate Intl messages in Dart to arb files
flutter pub run intl_translation:extract_to_arb --output-dir=assets/intl ./lib/**/*.dart

Database

Cassandra

  1. Alter Keyspace replication (for local)
ALTER KEYSPACE message WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1' };

Android

ADB

  1. Send SMS
adb emu sms send <sender> <msg>

terminal-cheatsheet's People

Contributors

lzhuor avatar

Stargazers

Roman avatar HU Ze avatar  avatar Luke Luo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.