Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
\ 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)
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
@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:]]’.
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.
# 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##*/}
@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
#!/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 / videoconv.bash
Last active July 5, 2017 07:11
Script For Video Conversion
#!/bin/bash
FFMPEG=/usr/bin/ffmpeg
HD_SUFFIX='_hd'
EMBED_WIDTH='640'
EMBED_HEIGHT='360'
SD_RESOLUTION=$EMBED_WIDTH'x'$EMBED_HEIGHT
@abhinavkorpal
abhinavkorpal / Ansible For Ubuntu
Last active June 23, 2017 09:37
Ansible Commands
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
ansible --version
ansible-playbook --version
ansible-galaxy --help
ansible --list-hosts all
sudo vi /etc/ansible/hosts
ansible -i dev --list-host all
sshpass -p 'nhGfJfU0' rsync -avu --exclude-from=/var/www/vhosts/IP ADRESSS/IP ADRESSS/dl-cpdpod/omit.txt -e ssh --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r -p --delete [email protected]:/var/www/vhostsIP ADRESSS/IP ADRESSS/xml-data/build-dir/1769473-1900545/ /var/www/vhosts/IP ADRESSS/IP ADRESSS/dl-cpdpod/