Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
PieterScheffers / wordpress_file_permissions.sh
Last active December 21, 2015 12:08
Wordpress File Permissions
# https://premium.wpmudev.org/blog/understanding-file-permissions/
# http://www.smashingmagazine.com/2014/05/proper-wordpress-filesystem-permissions-ownerships/
# Change directory permissions to 755 (d, rwx, r-x, r-x)
sudo find . -type d -exec chmod 755 {} +
find /path/to/your/wordpress/ -type d -exec chmod 755 {} \;
# Change file permissions to 644 (-, rw-, r--, r--)
sudo find . -type f -exec chmod 644 {} +
find /path/to/your/wordpress/ -type f -exec chmod 644 {} \;
@PieterScheffers
PieterScheffers / mysql_database.sh
Last active December 22, 2015 11:05
MySQL create database
# https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
# https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial
# Create a new database
CREATE DATABASE somedatabase
# Create a new user
CREATE USER 'someuser'@'localhost' IDENTIFIED BY 'somepassword';
# Delete a user
@PieterScheffers
PieterScheffers / generate_ssl_certificate.sh
Created December 22, 2015 21:07
Generate SSL Certificate
# https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
# Install letsencrypt
portmaster -ydbg --no-confirm security/py-letsencrypt
# Generate dhparam file
openssl dhparam -out dhparam.pem 4096
@PieterScheffers
PieterScheffers / install_composer.sh
Created December 24, 2015 10:38
Install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
@PieterScheffers
PieterScheffers / gist:ddc153c774170d8ede72
Last active February 17, 2016 08:31
FreeBSD find PHP ports installed (PHP5.6)
# Find php ports
portmaster -L | grep php | sed -e "s/===>>> //g" | sed -e "s/-5.6.18_1//g" | sed -e "s/-5.6.18//g" | sed -e "s/-1.0//g"
# Uninstall ports
portmaster -L | grep php | sed -e "s/===>>> //g" | sed -e "s/-5.6.18_1//g" | sed -e "s/-5.6.18//g" | sed -e "s/-1.0//g" | xargs -I {} sh -c 'portmaster -ye --no-confirm {}'
php56
php56-ctype
php56-curl
@PieterScheffers
PieterScheffers / start_stop_screen.sh
Last active March 29, 2016 12:24
Screen start stop
### Start screen session ###
# http://stackoverflow.com/questions/7049252/how-to-create-a-screen-executing-given-command
function exec_in_screen() {
name=$1
command=$2
screen -dmS $name sh; screen -S $name -X stuff "$command\n";
}
exec_in_screen "test" "ls"
@PieterScheffers
PieterScheffers / checkDNS.bat
Created April 5, 2016 10:00
Keep on checking DNS records for domain
@echo off
TITLE Find DNS TXT records for example.com
:dnslookup
nslookup -type=TXT example.com
GOTO wait
:wait
ping 127.0.0.1 -n 30 > nul
@PieterScheffers
PieterScheffers / find_unique_ips_access_log.sh
Created April 7, 2016 20:06
Find unique ips in Nginx access log
cat access.log | cut -d' ' -f1 | sort | uniq
# cat access.log Get contents of access.log
# cut -d' ' -f1 Split lines on space and get first part
# sort Sort lines
# uniq Get unique lines
@PieterScheffers
PieterScheffers / random_unix.sh
Last active April 11, 2016 20:10
Random Unix Pieces
# find all lines not beginning with an #
cat somefile | grep -v "^#"
# split all lines to get only the part before the first #
cat somefile | cut -d'#' -f1
# remove all comments
cat somefile | grep -v "^#" | cut -d'#' -f1
# List all users
@PieterScheffers
PieterScheffers / file_changed.sh
Last active April 12, 2016 09:09
Shell - file changed
MD5_FILE="md5_file"
FILE="somefile"
# create MD5 of somefile
md5=`md5 $FILE | cut -d'=' -f2 | tr -d " "`
# Write md5 to file
md5 > $MD5_FILE
# Get MD5 from file