Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
#!/bin/sh
# sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/^#/d' -e '/^$/d'
if [ -z $1 ]; then exit 0; else true; fi
xz -kf9 $1
printf '#!/bin/sh\nx=`tempfile`;echo ' > ${1}-min
base64 -w 0 ${1}.xz >> ${1}-min
printf '|base64 -d|xz -d>$x && chmod +x $x && $x $@; rm $x' >> ${1}-min
rm -f ${1}.xz
@abhinavkorpal
abhinavkorpal / AutoMySQLBackup
Created July 6, 2017 08:31
AutoMySQLBackup
# === AutoMySQLBackup ===
if [[ $run_all = false ]]; then
echo -n "Install AutoMySQLBackup? (y/n) [default: n]: "
read automysqlbackup
fi
if [ "$automysqlbackup" = "y" ] || [ $run_all = true ]; then
show_notice "Installing AutoMySQLBackup..."
apt-get install -y automysqlbackup
# remgit.sh
# Creates a remote git repository from the current local directory
# Configuration
# Replace SSH_USERNAME, SSH_HOST, SSH_GIT_PATH with your details
USER=SSH_USERNAME
HOST=SSH_HOST
GIT_PATH=SSH_GIT_PATH
REPO=${PWD##*/}
A regular expression may be followed by one of several repetition operators:
‘.’ The period ‘.’ matches any single character.
‘?’ The preceding item is optional and will be matched at most once.
‘*’ The preceding item will be matched zero or more times.
‘+’ The preceding item will be matched one or more times.
‘{n}’ The preceding item is matched exactly n times.
‘{n,}’ The preceding item is matched n or more times.
‘{,m}’ The preceding item is matched at most m times. This is a GNU extension.
‘{n,m}’ The preceding item is matched at least n times, but not more than m times.
@abhinavkorpal
abhinavkorpal / Backslash Character and Special Expressions
Created July 21, 2017 06:38
Backslash Character and Special Expressions
‘\b’ Match the empty string at the edge of a word.
‘\B’ Match the empty string provided it’s not at the edge of a word.
‘\<’ Match the empty string at the beginning of word.
‘\>’ Match the empty string at the end of word.
‘\w’ Match word constituent, it is a synonym for ‘[_[:alnum:]]’.
‘\W’ Match non-word constituent, it is a synonym for ‘[^_[:alnum:]]’.
‘\s’ Match whitespace, it is a synonym for ‘[[:space:]]’.
‘\S’ Match non-whitespace, it is a synonym for ‘[^[:space:]]’.
su #substitute user
id
echo $USER
su -l #full login shell
cat /etc/sudoers
sudo visudo
ssh -l root 192.168.0.3
vi /etc/ssh/sshd_config
systemctl restart sshd
\ Used to drop the special meaning of character
following it (discussed below)
[] Represent a character class
^ Matches the beginning
$ Matches the end
. Matches any character except newline
? Matches zero or one occurrence.
| Means OR (Matches with any of the characters
separated by it.
* Any number of occurrences (including 0 occurrences)
@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
@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: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