System Basic Setup

Vinodha kumara
18 min readAug 25, 2024

--

K8s

Ubuntu Install:

This is a bash script that is intended to automate the process of setting up a DevOps environment on a Ubuntu-based operating system. It can be used to set up a development environment on a new machine, ensuring that all the necessary tools and configurations are in place. This can be particularly useful for developers working on a team, as it ensures that everyone is using the same tools and configurations.

#!/bin/bash
# Update package index
echo -e -e "\e[93mUpdate package index...\e[0m"
sudo apt-get update
sudo apt-get install -y zsh
echo
# Install Terraform
echo -e -e "\e[93mInstall Terraform and add to PATH...\e[0m"
sudo snap install terraform --classic
# Add Terraform to PATH
echo'export PATH="$PATH:/usr/local/bin/terraform"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Ansible
echo -e "\e[93mInstall Ansible and add to PATH...\e[0m"
sudo apt-get install -y ansible
# Add Ansible to PATH
echo 'export PATH="$PATH:/usr/bin/ansible"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Git
sudo apt-get install -y git
# Add Git to Path
echo 'export PATH="$PATH:/usr/bin/git"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Docker
sudo snap install docker
# Add Docker to PATH
echo 'export PATH="$PATH:/usr/bin/docker"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Kubernetes
echo -e "\e[93mInstall Kubernetes and add to PATH...\e[0m"
snap install kubectl

# Add Kubernetes to PATH
echo 'export PATH="$PATH:/usr/local/bin/kubectl"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Helm
echo -e "\e[93mInstall Helm and add to PATH...\e[0m"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
# Add Helm to PATH
echo 'export PATH="$PATH:/usr/local/bin/helm"' >> ~/.zshrc
source ~/.zshrc
echo
# Install AWS CLI
echo -e "\e[93mInstall AWS CLI and add to PATH...\e[0m"
sudo apt-get install -y awscli
# Add AWS CLI to PATH
echo 'export PATH="$PATH:/usr/local/bin/aws"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubie to PATH
echo 'export PATH="$PATH:~/.kubie"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubectl aliases to zshrc file
## Generate a secure password and copy it to clipboard
echo -e "\e[93mAdd kubectl aliases to zshrc file...\e[0m"
cat > ~/.zshrc <<- EOS
alias ll="ls -lah"
alias vissh="vi ~/.ssh/config"
alias kgp="k get pods -o wide"
alias kgn="k get nodes -o wide"
alias kgs="k get service"
alias kgpv="k get pv"
alias kgpvc="k get pvc"
alias kd="k describe"
alias kns="kubie ns"
alias kcx="kubie ctx"
alias pod-check="kgp -A -o wide | grep -v Running | grep -v Comp"
alias pod-count="kgp -A | wc -l"

## SSL
alias certexp="openssl x509 -enddate -noout -in"
alias certcheck="openssl x509 -noout -text -in"
alias caverify="openssl verify -CAfile"
## Networking
alias mtr="sudo /usr/local/sbin/mtr"
alias nlp="nslookup"
## Git
alias gcm="git commit -m"
alias gp="git push"
alias gpt="git push --tags"
## Ansible
alias ansible="/usr/local/opt/ansible@2.8/bin/ansible"
alias ansible-playbook="/usr/local/opt/ansible@2.8/bin/ansible-playbook"
alias ansible2="/usr/local/opt/ansible@2.9/bin/ansible"
alias ansible2-playbook="/usr/local/opt/ansible@2.9/bin/ansible-playbook"
alias ansible4="/usr/local/opt/ansible/bin/ansible"
alias ansible4-galaxy="/usr/local/opt/ansible/bin/ansible-galaxy"
alias ansible4-playbook="/usr/local/opt/ansible/bin/ansible-playbook"
## Helm
alias helm="/usr/local/opt/helm/bin/helm"
## Zsh Auto Complete
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
EOS

source ~/.zshrc

CentOS Install (Amazon Linux 2)

#!/bin/bash
# Update package index
echo -e "\e[93mUpdate package index...\e[0m"
sudo yum update -y
sudo yum install -y zsh
echo
# Install Terraform
echo -e "\e[93mInstall Terraform and add to PATH...\e[0m"
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform
echo 'export PATH="$PATH:/usr/local/bin/terraform"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Ansible
echo -e "\e[93mInstall Ansible and add to PATH...\e[0m"
sudo amazon-linux-extras install -y ansible2
echo 'export PATH="$PATH:/usr/bin/ansible"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Git
sudo yum install -y git
echo 'export PATH="$PATH:/usr/bin/git"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Docker
sudo yum install -y yum-utils
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
echo 'export PATH="$PATH:/usr/bin/docker"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Kubernetes
echo -e "\e[93mInstall Kubernetes and add to PATH...\e[0m"
sudo cat > /etc/yum.repos.d/kubernetes.repo <<-EOS
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOS
sudo yum install -y kubectl
echo 'export PATH="$PATH:/usr/bin/kubectl"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Helm
echo -e "\e[93mInstall Helm and add to PATH...\e[0m"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
echo 'export PATH="$PATH:/usr/local/bin/helm"' >> ~/.zshrc
source ~/.zshrc
echo
# Install AWS CLI
echo -e "\e[93mInstall AWS CLI and add to PATH...\e[0m"
sudo yum install
echo 'export PATH="$PATH:/usr/local/bin/aws"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubie to PATH
echo 'export PATH="$PATH:~/.kubie"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubectl aliases to zshrc file
## Generate a secure password and copy it to clipboard
echo -e "\e[93mAdd kubectl aliases to zshrc file...\e[0m"
cat > ~/.zshrc <<- EOS
alias ll="ls -lah"
alias vissh="vi ~/.ssh/config"
alias kgp="k get pods -o wide"
alias kgn="k get nodes -o wide"
alias kgs="k get service"
alias kgpv="k get pv"
alias kgpvc="k get pvc"
alias kd="k describe"
alias kns="kubie ns"
alias kcx="kubie ctx"
alias pod-check="kgp -A -o wide | grep -v Running | grep -v Comp"
alias pod-count="kgp -A | wc -l"
## SSL
alias certexp="openssl x509 -enddate -noout -in"
alias certcheck="openssl x509 -noout -text -in"
alias caverify="openssl verify -CAfile"
## Networking
alias mtr="sudo /usr/local/sbin/mtr"
alias nlp="nslookup"
## Git
alias gcm="git commit -m"
alias gp="git push"
alias gpt="git push --tags"
## Ansible
alias ansible="/usr/local/opt/ansible@2.8/bin/ansible"
alias ansible-playbook="/usr/local/opt/ansible@2.8/bin/ansible-playbook"
alias ansible2="/usr/local/opt/ansible@2.9/bin/ansible"
alias ansible2-playbook="/usr/local/opt/ansible@2.9/bin/ansible-playbook"
alias ansible4="/usr/local/opt/ansible/bin/ansible"
alias ansible4-galaxy="/usr/local/opt/ansible/bin/ansible-galaxy"
alias ansible4-playbook="/usr/local/opt/ansible/bin/ansible-playbook"
## Helm
alias helm="/usr/local/opt/helm/bin/helm"
## Zsh Auto Complete
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
EOS
source ~/.zshrc 1,3 Top

MacOS Install

The scripts provided above are for Ubuntu Linux and CentOS (Amazon Linux 2) and use different package tools (apt-get/yum) for package management. MacOS uses a different package manager called Homebrew, so the script would need to be modified accordingly. Here is an example of how the script could be converted to work on macOS:

#!/bin/bash
# Update package index
echo -e "\e[93mUpdate package index...\e[0m"
brew update
brew install zsh
echo
# Install Terraform
echo -e "\e[93mInstall Terraform and add to PATH...\e[0m"
brew install terraform
# Add Terraform to PATH
echo 'export PATH="$PATH:/usr/local/bin/terraform"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Ansible
echo -e "\e[93mInstall Ansible and add to PATH...\e[0m"
brew install ansible
# Add Ansible to PATH
echo 'export PATH="$PATH:/usr/local/bin/ansible"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Git
brew install git
# Add Git to Path
echo 'export PATH="$PATH:/usr/local/bin/git"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Docker
brew install docker
# Add Docker to PATH
echo 'export PATH="$PATH:/usr/local/bin/docker"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Kubernetes
echo -e "\e[93mInstall Kubernetes and add to PATH...\e[0m"
brew install kubectl
# Add Kubernetes to PATH
echo 'export PATH="$PATH:/usr/local/bin/kubectl"' >> ~/.zshrc
source ~/.zshrc
echo
# Install Helm
echo -e "\e[93mInstall Helm and add to PATH...\e[0m"
brew install helm
# Add Helm to PATH
echo 'export PATH="$PATH:/usr/local/bin/helm"' >> ~/.zshrc
source ~/.zshrc
echo
# Install AWS CLI
echo -e "\e[93mInstall AWS CLI and add to PATH...\e[0m"
brew install awscli
# Add AWS CLI to PATH
echo 'export PATH="$PATH:/usr/local/bin/aws"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubie to PATH
echo 'export PATH="$PATH:~/.kubie"' >> ~/.zshrc
source ~/.zshrc
echo
# Add kubectl aliases to zshrc file
## Generate a secure password and copy it to clipboard
echo -e "\e[93mAdd kubectl aliases to zshrc file...\e[0m"
cat > ~/.zshrc <<- EOS
alias ll="ls -lah"
alias vissh="vi ~/.ssh/config"
alias kgp="k get pods -o wide"
alias kgn="k get nodes -o wide"
alias kgs="k get service"
alias kgpv="k get pv"
alias kgpvc="k get pvc"
alias kd="k describe"
alias kns="kubie ns"
alias kcx="kubie ctx"
alias pod-check="kgp -A -o wide | grep -v Running | grep -v Comp"
alias pod-count="kgp -A | wc -l"
## SSL
alias certexp="openssl x509 -enddate -noout -in"
alias certcheck="openssl x509 -noout -text -in"
alias caverify="openssl verify -CAfile"
## Networking
alias mtr="sudo /usr/local/sbin/mtr"
alias nlp="nslookup"
## Git
alias gcm="git commit -m"
alias gp="git push"
alias gpt="git push --tags"
## Ansible
alias ansible="/usr/local/opt/ansible@2.8/bin/ansible"
alias ansible-playbook="/usr/local/opt/ansible@2.8/bin/ansible-playbook"
alias ansible2="/usr/local/opt/ansible@2.9/bin/ansible"
alias ansible2-playbook="/usr/local/opt/ansible@2.9/bin/ansible-playbook"
alias ansible4="/usr/local/opt/ansible/bin/ansible"
alias ansible4-galaxy="/usr/local/opt/ansible/bin/ansible-galaxy"
alias ansible4-playbook="/usr/local/opt/ansible/bin/ansible-playbook"
## Helm
alias helm="/usr/local/opt/helm/bin/helm"
## Zsh Auto Complete
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
EOS
source ~/.zshrc


# Shortcuts
alias k="kubectl "
alias kg="k get "
alias po="kg po "
alias ke="k edit"
alias kd="k describe "
alias pod="kd po "
alias kc="k create "
alias no="kg nodes "
alias ka="k apply -f "
alias kd="kubectl delete -f "
alias ks="kubectl get svc "
alias kssh="kubectl exec -it "
alias hi="helm install "
alias hu="helm uninstall "
alias kga="kubectl get all "
alias hl="helm list "
alias klogs="k logs -f "
alias hs="helm status "

Git

alias add="git add . "
alias dif="git diff "
alias stats="git status "
alias commit="git commit -m "
alias push="git push origin "

Short Cuts

# pgAdmin
alias pgadmin='./Desktop/pgAdmin\ 4.app/Contents/MacOS/pgAdmin4'

# List files in color
alias ls='ls -G'

# Kafka live
alias kafka-live="ssh -i /Users/vinodhakumaral/Documents/secretes/eks-nodes-prod.pem ubuntu@10.51.11.35"

# Shows all Shortcut keys
alias help='cd /Users/vinodhakumaral/Documents/scripts/;bat --style=plain help;cd -'

# Daily huddle
alias huddle=open -a "Google Chrome" "https://meet.google.com/yfx-ejaw-pxs"

# Kafka live
alias kafka_live="ssh -i "/Users/vinodhakumaral/Documents/secretes/eks-nodes-prod.pem" ubuntu@10.51.11.35"

# plugins

# Helm
alias charts='open -a "Google Chrome" https://artifacthub.io/packages/helm/airflow-helm/airflow'

#plugins=(zsh-autosuggestions)

# projects folders
alias projects="cd /Users/vinodhakumaral/Documents/projects"

# Scripts
alias scripts="cd /Users/vinodhakumaral/Documents/scripts"

# secrete Keys
alias keys="cd /Users/vinodhakumaral/Documents/secretes"

# Jenkins
alias jenkins-cron='open -a "Google Chrome" https://jenkins-cron-notif.kooapp.com/'
alias jenkins-dev='open -a "Google Chrome" https://jenkins-dev.kooapp.com/'
alias jenkins-prod='open -a "Google Chrome" https://jenkins-prod.kooapp.com/'
alias jenkins-preprod='open -a "Google Chrome" https://jenkins-preprod.kooapp.com/'

# Rancher
alias dev-rancher='open -a "Google Chrome" https://dev-rancher.kooapp.com/dashboard/c/c-qcntk/explorer#events'
alias preprod-rancher='open -a "Google Chrome" https://preprod-rancher.kooapp.com/dashboard/c/c-r2dh9/explorer#events'

# Kubecost
alias kubecost='open -a "Google Chrome" https://kubecost.kooapp.com/'

# Bastion
alias dev='ssh vinodha.k@172.31.52.196 -i ~/.ssh/id_rsa_password_less'
alias preprod='ssh vinodha.k@10.0.63.2 -i ~/.ssh/id_rsa_password_less'
alias prod='ssh vinodha.k@10.51.118.183 -i ~/.ssh/id_rsa_password_less'

# AWS old-prod
alias aws-old-prod='open -a "Google Chrome" "https://ap-south-1.signin.aws.amazon.com/oauth?response_type=code&client_id=arn%3Aaws%3Aiam%3A%3A015428540659%3Auser%2Fec2&redirect_uri=https%3A%2F%2Fap-south-1.console.aws.amazon.com%2Fec2%2Fv2%2Fhome%3Fregion%3Dap-south-1%26state%3DhashArgs%2523Instances%253Av%253D3%253Bsearch%253D%253Akufb%26isauthcode%3Dtrue&forceMobileLayout=0&forceMobileApp=0&code_challenge=HuA1NhgzNtC_rLYjulBIphCPf0-I3A73t0fDaJIbeec&code_challenge_method=SHA-256"'

# Jira
alias jira='open -a "Google Chrome" https://koo-projects.atlassian.net/jira/software/projects/KD/boards/11'

# Docs
alias doc-google-site='open -a "Google Chrome" https://sites.google.com/d/1V3NNDF01qxk3gGUXZvHTK04M2G_zsn6-/p/1-mz_Esw9sbYoXPuhHuHigZAPccnI_PfF/edit'

# Plans
alias cal-google='open -a "Google Chrome" https://calendar.google.com/calendar/u/0/r/month'

# Meetings
alias meet='open -a "Google Chrome" "https://meet.google.com/qtq-txgc-dyt" | echo "https://meet.google.com/qtq-txgc-dyt
" | pbcopy ; open -a "Slack"'

# Gmail
alias gmail='open -a "Google Chrome" https://mail.google.com/mail/u/0/#inbox'
alias gmail-my='open -a "Google Chrome" https://mail.google.com/mail/u/1/#inbox'

# GitHub
alias preprod_git="cd /Users/vinodhakumaral/Documents/projects/envs/preprod"
alias dev_git="cd /Users/vinodhakumaral/Documents/projects/envs/dev"
alias prod_git="cd /Users/vinodhakumaral/Documents/projects/envs/prod"

# PATH dont delete
export PATH="/custom/bin:$PATH"

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"


# Commands shortcut
# clear console
alias c='clear'
## get rid of command not found ##
alias cd..='cd ..'

## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias h='history'
alias now='date +"%T"'
alias nowtime=now
#show open ports
alias ports='netstat -tulanp'
# install with apt-get
alias apt-get="sudo apt-get"
# become root #
alias root='sudo -i'
alias su='sudo -i'

## pass options to free ##
alias meminfo='free -m -l -t'

## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'

## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

## Get server cpu info ##
alias cpuinfo='lscpu'
## set some other defaults ##
alias df='df -H'
alias du='du -ch'

# top is atop, just like vi is vim
alias top='atop'

Help Command


Commands shortcut
-----------------

huddle - Connect to Syncup Call

help - Shows all shortcut keys

A quick way to get out of current directory
c - clear console
cd.. - cd ..
.. - cd ..
... - 'cd ../../../'
.... - 'cd ../../../../'
..... - 'cd ../../../../'
.4 - 'cd ../../../../'
.5 - 'cd ../../../../..'

Colorize the grep command output for ease of use (good for log files)
grep - grep with color 'grep --color=auto'
egrep - egrep with color 'egrep --color=auto'
fgrep - fgrep with color'fgrep --color=auto'
h - shows history
now - current date
nowtime - current date
show open ports
ports - show open ports


pass options to free
meminfo - Show memory information

get top process eating memory
psmem - show memory usage in sorted order
psmem10 - show memory usage in sorted order first 10 lines

get top process eating cpu
pscpu - show CPU usage in sorted order
pscpu10 - show CPU usage in sorted order first 10 lines


cpuinfo - Get server cpu info
set some other defaults
df - Show default storage allocation
du - Show Memory allocated by files/folders

top - top is atop, just like vi is vim

yum - install with yum

become root
root
su


Kubernetes services
k - kubectl
kg - List Services
po,pod - Get Pods
ke - kubectl edit
kd - kubectl describe
kc - kubectl create
ka - kubectl apply -f
kd - kubectl delete -f
ks - Get Services
kssh - Ssh into conatiner add " -- /bin/bash" in last
kga - Get all Services
klogs - Show kubernetelogs

Nodes
no - Get Nodes

Helm
hl - List Helm
hs - helm status
hi - helm install
hu - helm uninstall

My .zshrc

# pgAdmin
alias pgadmin='./Desktop/pgAdmin\ 4.app/Contents/MacOS/pgAdmin4'

# List files in color
alias ls='ls -G'

# Kafka live
alias kafka-live="ssh -i /Users/vinodhakumaral/Documents/secretes/eks-nodes-prod.pem ubuntu@10.51.11.35"

# Shows all Shortcut keys
alias help='cd /Users/vinodhakumaral/Documents/scripts/;bat --style=plain help;cd -'

# Daily huddle
alias huddle=open -a "Google Chrome" "https://meet.google.com/yfx-ejaw-pxs"

# Kafka live
alias kafka_live="ssh -i "/Users/vinodhakumaral/Documents/secretes/eks-nodes-prod.pem" ubuntu@10.51.11.35"

# plugins

# Helm
alias charts='open -a "Google Chrome" https://artifacthub.io/packages/helm/airflow-helm/airflow'

#plugins=(zsh-autosuggestions)

# projects folders
alias projects="cd /Users/vinodhakumaral/Documents/projects"

# Scripts
alias scripts="cd /Users/vinodhakumaral/Documents/scripts"

# secrete Keys
alias keys="cd /Users/vinodhakumaral/Documents/secretes"

# Jenkins
alias jenkins-cron='open -a "Google Chrome" https://jenkins-cron-notif.kooapp.com/'
alias jenkins-dev='open -a "Google Chrome" https://jenkins-dev.kooapp.com/'
alias jenkins-prod='open -a "Google Chrome" https://jenkins-prod.kooapp.com/'
alias jenkins-preprod='open -a "Google Chrome" https://jenkins-preprod.kooapp.com/'

# Rancher
alias dev-rancher='open -a "Google Chrome" https://dev-rancher.kooapp.com/dashboard/c/c-qcntk/explorer#events'
alias preprod-rancher='open -a "Google Chrome" https://preprod-rancher.kooapp.com/dashboard/c/c-r2dh9/explorer#events'

# Kubecost
alias kubecost='open -a "Google Chrome" https://kubecost.kooapp.com/'

# Bastion
alias dev='ssh vinodha.k@172.31.52.196 -i ~/.ssh/id_rsa_password_less'
alias preprod='ssh vinodha.k@10.0.63.2 -i ~/.ssh/id_rsa_password_less'
alias prod='ssh vinodha.k@10.51.118.183 -i ~/.ssh/id_rsa_password_less'

# AWS old-prod
alias aws-old-prod='open -a "Google Chrome" "https://ap-south-1.signin.aws.amazon.com/oauth?response_type=code&client_id=arn%3Aaws%3Aiam%3A%3A015428540659%3Auser%2Fec2&redirect_uri=https%3A%2F%2Fap-south-1.console.aws.amazon.com%2Fec2%2Fv2%2Fhome%3Fregion%3Dap-south-1%26state%3DhashArgs%2523Instances%253Av%253D3%253Bsearch%253D%253Akufb%26isauthcode%3Dtrue&forceMobileLayout=0&forceMobileApp=0&code_challenge=HuA1NhgzNtC_rLYjulBIphCPf0-I3A73t0fDaJIbeec&code_challenge_method=SHA-256"'

# Jira
alias jira='open -a "Google Chrome" https://koo-projects.atlassian.net/jira/software/projects/KD/boards/11'

# Docs
alias doc-google-site='open -a "Google Chrome" https://sites.google.com/d/1V3NNDF01qxk3gGUXZvHTK04M2G_zsn6-/p/1-mz_Esw9sbYoXPuhHuHigZAPccnI_PfF/edit'

# Plans
alias cal-google='open -a "Google Chrome" https://calendar.google.com/calendar/u/0/r/month'

# Meetings
alias meet='open -a "Google Chrome" "https://meet.google.com/qtq-txgc-dyt" | echo "https://meet.google.com/qtq-txgc-dyt
" | pbcopy ; open -a "Slack"'

# Gmail
alias gmail='open -a "Google Chrome" https://mail.google.com/mail/u/0/#inbox'
alias gmail-my='open -a "Google Chrome" https://mail.google.com/mail/u/1/#inbox'

# GitHub
alias preprod_git="cd /Users/vinodhakumaral/Documents/projects/envs/preprod"
alias dev_git="cd /Users/vinodhakumaral/Documents/projects/envs/dev"
alias prod_git="cd /Users/vinodhakumaral/Documents/projects/envs/prod"

# PATH dont delete
export PATH="/custom/bin:$PATH"

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"


# Commands shortcut
# clear console
alias c='clear'
## get rid of command not found ##
alias cd..='cd ..'

## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias h='history'
alias now='date +"%T"'
alias nowtime=now
#show open ports
alias ports='netstat -tulanp'
# install with apt-get
alias apt-get="sudo apt-get"
# become root #
alias root='sudo -i'
alias su='sudo -i'

## pass options to free ##
alias meminfo='free -m -l -t'

## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'

## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

## Get server cpu info ##
alias cpuinfo='lscpu'
## set some other defaults ##
alias df='df -H'
alias du='du -ch'

# top is atop, just like vi is vim
alias top='atop'


alias cd-='cd -'
alias ......=../../../../..
alias 1='cd -1'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'
alias _='sudo '
alias dkcpdown='docker-compose down'
alias dkcpstart='docker-compose start'
alias dkcpstop='docker-compose stop'
alias dkcpup='docker-compose up -d'
alias dkimgs='docker images'
alias dkps='docker ps'
alias dkpsa='docker ps -a'
alias dkst='docker stats'
alias egrep='grep -E --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
alias fgrep='grep -F --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
alias g=git
alias ga='git add'
alias gaa='git add --all'
alias gam='git am'
alias gama='git am --abort'
alias gamc='git am --continue'
alias gams='git am --skip'
alias gamscp='git am --show-current-patch'
alias gap='git apply'
alias gapa='git add --patch'
alias gapt='git apply --3way'
alias gau='git add --update'
alias gav='git add --verbose'
alias gb='git branch'
alias gbD='git branch --delete --force'
alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbg='LANG=C git branch -vv | grep ": gone\]"'
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '\''{print $1}'\'' | xargs git branch -D'
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '\''{print $1}'\'' | xargs git branch -d'
alias gbl='git blame -w'
alias gbm='git branch --move'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsn='git bisect new'
alias gbso='git bisect old'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gc='git commit --verbose'
alias 'gc!'='git commit --verbose --amend'
alias gcB='git checkout -B'
alias gca='git commit --verbose --all'
alias 'gca!'='git commit --verbose --all --amend'
alias gcam='git commit --all --message'
alias 'gcan!'='git commit --verbose --all --no-edit --amend'
alias 'gcans!'='git commit --verbose --all --signoff --no-edit --amend'
alias gcas='git commit --all --signoff'
alias gcasm='git commit --all --signoff --message'
alias gcb='git checkout -b'
alias gcd='git checkout $(git_develop_branch)'
alias gcf='git config --list'
alias gcl='git clone --recurse-submodules'
alias gclean='git clean --interactive -d'
alias gcm='git checkout $(git_main_branch)'
alias gcmsg='git commit --message'
alias 'gcn!'='git commit --verbose --no-edit --amend'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
alias gcount='git shortlog --summary --numbered'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit --gpg-sign'
alias gcsm='git commit --signoff --message'
alias gcss='git commit --gpg-sign --signoff'
alias gcssm='git commit --gpg-sign --signoff --message'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gdcw='git diff --cached --word-diff'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdup='git diff @{upstream}'
alias gdw='git diff --word-diff'
alias gf='git fetch'
alias gfa='git fetch --all --prune --jobs=10'
alias gfg='git ls-files | grep'
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ggpull='git pull origin "$(git_current_branch)"'
alias ggpur=ggu
alias ggpush='git push origin "$(git_current_branch)"'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias ghh='git help'
alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gk='\gitk --all --branches &!'
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
alias gl='git pull'
alias glg='git log --stat'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glgp='git log --stat --patch'
alias glo='git log --oneline --decorate'
alias globurl='noglob urlglobber '
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
alias glp=_git_log_prettily
alias gluc='git pull upstream $(git_current_branch)'
alias glum='git pull upstream $(git_main_branch)'
alias gm='git merge'
alias gma='git merge --abort'
alias gmom='git merge origin/$(git_main_branch)'
alias gms='git merge --squash'
alias gmtl='git mergetool --no-prompt'
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
alias gmum='git merge upstream/$(git_main_branch)'
alias gp='git push'
alias gpd='git push --dry-run'
alias gpf='git push -f'
alias 'gpf!'='git push --force'
alias gpoat='git push origin --all && git push origin --tags'
alias gpod='git push origin --delete'
alias gpr='git pull --rebase'
alias gpra='git pull --rebase --autostash'
alias gprav='git pull --rebase --autostash -v'
alias gpristine='git reset --hard && git clean --force -dfx'
alias gprom='git pull --rebase origin $(git_main_branch)'
alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
alias gprv='git pull --rebase -v'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes'
alias gpu='git push upstream'
alias gpv='git push --verbose'
alias gr='git remote'
alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbd='git rebase $(git_develop_branch)'
alias grbi='git rebase --interactive'
alias grbm='git rebase $(git_main_branch)'
alias grbo='git rebase --onto'
alias grbom='git rebase origin/$(git_main_branch)'
alias grbs='git rebase --skip'
alias grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
alias grev='git revert'
alias grh='git reset'
alias grhh='git reset --hard'
alias grhk='git reset --keep'
alias grhs='git reset --soft'
alias grm='git rm'
alias grmc='git rm --cached'
alias grmv='git remote rename'
alias groh='git reset origin/$(git_current_branch) --hard'
alias grrm='git remote remove'
alias grs='git restore'
alias grset='git remote set-url'
alias grss='git restore --source'
alias grst='git restore --staged'
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --'
alias grup='git remote update'
alias grv='git remote --verbose'
alias gsb='git status --short --branch'
alias gsd='git svn dcommit'
alias gsh='git show'
alias gsi='git submodule init'
alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase'
alias gss='git status --short'
alias gst='git status'
alias gsta='git stash push'
alias gstaa='git stash apply'
alias gstall='git stash --all'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --patch'
alias gstu='gsta --include-untracked'
alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch --create'
alias gswd='git switch $(git_develop_branch)'
alias gswm='git switch $(git_main_branch)'
alias gta='git tag --annotate'
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
alias gts='git tag --sign'
alias gtv='git tag | sort -V'
alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
alias gup=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gup%F{yellow}\' is a deprecated alias, using \'%F{green}gpr%F{yellow}\' instead.%f"\n gpr'
alias gupa=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gupa%F{yellow}\' is a deprecated alias, using \'%F{green}gpra%F{yellow}\' instead.%f"\n gpr'


alias gupav=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gupav%F{yellow}\' is a deprecated alias, using \'%F{green}gprav%F{yellow}\' instead.%f"\n gprav'
alias gupom=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gupom%F{yellow}\' is a deprecated alias, using \'%F{green}gprom%F{yellow}\' instead.%f"\n gprom'
alias gupomi=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gupomi%F{yellow}\' is a deprecated alias, using \'%F{green}gpromi%F{yellow}\' instead.%f"\n gpromi'
alias gupv=$'\n print -Pu2 "%F{yellow}[oh-my-zsh] \'%F{red}gupv%F{yellow}\' is a deprecated alias, using \'%F{green}gprv%F{yellow}\' instead.%f"\n gprv'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
alias gwt='git worktree'
alias gwta='git worktree add'
alias gwtls='git worktree list'
alias gwtmv='git worktree move'
alias gwtrm='git worktree remove'
alias history=omz_history
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias ls='ls -G'
alias lsa='ls -lah'
alias md='mkdir -p'
alias ohmyzsh='vim ~/.oh-my-zsh'
alias rd=rmdir
alias run-help=man
alias which-command=whence
alias zshconfig='vim ~/.zshrc'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias asia='gcloud container clusters get-credentials prod-cluster --region asia-south1 --project p-koo-wrkld-prod-base-6acd'

alias hi='helm install '
alias hl='helm list '
alias hs='helm status '
alias hu='helm uninstall '
alias k='kubectl '
alias ka='k apply -f '
alias kc='k create '
alias kd='kubectl delete -f '
alias ke='k edit'
alias kg='k get '
alias kga='kubectl get all '
alias klogs='k logs -f '
alias ks='kubectl get svc '
alias kssh='kubectl exec -it '
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
alias meminfo='free -m -l -t'
alias names='kubectl config set-context --current --namespace '
alias no='kg nodes '
alias now='date +"%T"'
alias nowtime='now'
alias po='kg po '
alias pod='kd po '
alias ports='netstat -tulanp'
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias root='sudo su - '
alias sing='gcloud container clusters get-credentials prod-cluster-singapore --region asia-southeast1 --project p-koo-wrkld-prod-base-6acd'

My .bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


# Commands shortcut
# clear console
alias c='clear'

## get rid of command not found ##
alias cd..='cd ..'

## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'

## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias h='history'
alias now='date +"%T"'
alias nowtime=now

#show open ports
alias ports='netstat -tulanp'
# install with apt-get
alias apt-get="sudo apt-get"
# become root #
alias root='sudo su - '
alias su='sudo su - '

## pass options to free ##
alias meminfo='free -m -l -t'

## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'

## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

## Get server cpu info ##
alias cpuinfo='lscpu'
## set some other defaults ##
alias df='df -H'
alias du='du -ch'

# List
alias bat='usr/bin/bat'
alias help='cd ~/;bat --style=plain help;cd -'

# top is atop, just like vi is vim
alias top='atop'

alias k="kubectl "
alias kg="k get "
alias po="kg po "
alias ke="k edit"
alias kd="k describe "
alias pod="kd po "
alias kc="k create "
alias no="kg nodes "
alias ka="k apply -f "
alias kd="kubectl delete -f "
alias ks="kubectl get svc "
alias kssh="kubectl exec -it "
alias hi="helm install "
alias hu="helm uninstall "
alias kga="kubectl get all "
alias hl="helm list "
alias klogs="k logs -f "
alias hs="helm status "
alias h="history"

Switch Namespaces

Between namespace also previous ns using “-”

# Namespace switching function with proper previous namespace tracking
ns() {
# Get the current namespace
CURRENT_NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}')

# If the argument is "-", switch to the previous namespace
if [ "$1" = "-" ]; then
if [ -z "$PREV_NAMESPACE" ]; then
echo "No previous namespace recorded."
else
# Swap between current and previous namespace
kubectl config set-context --current --namespace="$PREV_NAMESPACE"
echo "Switched back to previous namespace: $PREV_NAMESPACE"

# Now update PREV_NAMESPACE to hold the CURRENT_NAMESPACE
TEMP_NAMESPACE=$CURRENT_NAMESPACE
CURRENT_NAMESPACE=$PREV_NAMESPACE
PREV_NAMESPACE=$TEMP_NAMESPACE
fi
else
# Store the current namespace before switching
PREV_NAMESPACE=$CURRENT_NAMESPACE

# Switch to the new namespace
kubectl config set-context --current --namespace="$1"
echo "Switched to namespace: $1"
fi
}

--

--

Vinodha kumara

DevSecOps, MLOps, Cloud Computing, DE, ML, DL, Programmer, Blogger, Volunteer