Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
@abhinavkorpal
abhinavkorpal / sed (linux)
Created July 13, 2018 12:52
Find and replace text within a file using commands
sed -i 's/original/new/g' file.txt
Explanation:
sed = Stream EDitor
-i = in-place (i.e. save back to the original file)
The command string:
s = the substitute command
original = a regular expression describing the word to replace (or just the word itself)
@abhinavkorpal
abhinavkorpal / README-oneshot-systemd-service.md
Created March 7, 2018 06:22 — forked from drmalex07/README-oneshot-systemd-service.md
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@abhinavkorpal
abhinavkorpal / HTTP Strict Transport Security ( HSTS )
Created February 25, 2018 05:55
HTTP Strict Transport Security ( HSTS )
HTTP Strict Transport Security
@abhinavkorpal
abhinavkorpal / Self-Sign the CSR
Created February 25, 2018 02:57
Self-Sign the CSR
openssl x509 -req -sha256 -in server.csr \
-signkey server.key -out server.crt
cat server.crt
openssl x509 -noout -text -in server.crt
man x509, man req; man genrsa
@abhinavkorpal
abhinavkorpal / Certificate Signing Request
Created February 25, 2018 02:53
Certificate Signing Request
openssl req -new -key server.key -out server.csr
cat server.csr
openssl req -noout -text -in server.csr
@abhinavkorpal
abhinavkorpal / kubernetes
Created January 16, 2018 12:30
Kubernetes
create a cluster:
minikube version
minikube start
kubectl version
kubectl cluster-info
kubectl get nodes
@abhinavkorpal
abhinavkorpal / Common vi editor command list
Created January 16, 2018 09:58
Common vi editor command list
To insert new text esc + i ( You have to press 'escape' key then 'i')
To save file esc + : + w (Press 'escape' key then 'colon' and finally 'w')
To save file with file name (save as) esc + : + w "filename"
To quit the vi editor esc + : + q
To quit without saving esc + : + q!
To save and quit vi editor esc + : + wq
To search for specified word in forward direction esc + /word (Press 'escape' key, type /word-to-find, for e.g. to find word 'shri', type as
/shri)
To continue with search n
To search for specified word in backward direction esc + ?word (Press 'escape' key, type word-to-find)
@abhinavkorpal
abhinavkorpal / upgarde.sh
Created October 10, 2017 09:15
Shell Script for Upgrade Ubuntu via APT in one step
sudo apt-get update -o Dir::Etc::SourceList=/etc/apt/security.sources.list
sudo apt-get upgrade -o Dir::Etc::SourceList=/etc/apt/security.sources.list
sudo apt-get autoremove
@abhinavkorpal
abhinavkorpal / upgarde.sh
Created October 10, 2017 09:15
Shell Script for Upgrade Ubuntu via APT in one step
sudo aptitude update
echo "------------------------------------------------------------------------------------------------------------------------------------"
sudo aptitude upgrade -y
echo "-----------------------------------------------------------------------------------------------------------------------------------"
sudo aptitude autoclean
echo "-----------------------------------------------------------------------------------------------------------------------------------"
sudo apt-get autoclean
echo "-----------------------------------------------------------------------------------------------------------------------------------"
sudo apt-get autoremove
echo "-----------------------------------------------------------------------------------------------------------------------------------"
@abhinavkorpal
abhinavkorpal / upgarde.sh
Created October 10, 2017 09:13
Shell Script for Upgrade Ubuntu via APT in one step
#!/bin/bash
TEXT_RESET='\e[0m'
TEXT_YELLOW='\e[0;33m'
TEXT_RED_B='\e[1;31m'
sudo apt-get update
echo -e $TEXT_YELLOW
echo 'APT update finished...'
echo -e $TEXT_RESET