Skip to content

Instantly share code, notes, and snippets.

@yourdesigncoza
yourdesigncoza / reboot-server-cron
Created May 3, 2013 19:30
Reboot server once a day
#!/bin/bash
#THX TO @chrishough : http://noconformity.com/blog/2013/04/15/linux-server-automation-scripts/
#start
#-----------------------------------------------------------------------
#restart server
#DateStamp=$(date +"%Y%m%d %k:%M:%S");
#echo $DateStamp >> /var/log/cron.reboot.log;
/sbin/shutdown -r now
@yourdesigncoza
yourdesigncoza / backup-wordpress-content-directory-incrimentally
Created May 3, 2013 16:03
Recovering a WordPress site thats been compromised is not fun, where to find all those images etc. etc. The solution, run a daily BackUp of the whole wp-content folder, then you have everything to restore your site ::: However if you backup your site every day this can drain your server resources if you have thousands of images ( remember each i…
# Recovering a WordPress site thats been compromised is not fun, where to find all those images etc. etc. The solution, run a daily BackUp of the whole wp-content folder, then you have everything to restore your site ::: However if you backup your site every day this can drain your server resources if you have thousands of images ( remember each image in WP is duplicated AT LEAST 3 times ), imagine your BU running while you have a reasonable traffic :::
# My solution is as follows ::: I used rsync which has a function that compares files then only adds new files/folders also removing files/folders not needed any more ::: I also wanted a 7 day backup solution, so what I do is I create a file each day "Uniquely Stamped" with each day eg. Monday is 01, Tuesday 02 you get the picture ::: Once we move on to the eight day we will be back where we started day 01 ( if BU's commenced on a Monday ) , on day 8, what will happen is that only files/folders added or deleted will be added and removed from the BU created a
@yourdesigncoza
yourdesigncoza / rsync-bu-wordpress
Created May 2, 2013 21:06
RSYNC is a software application for Unix systems which synchronizes files and directories from one location to another
# RSYNC is a software application for Unix systems which synchronizes files and directories from one location to another :::
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Backing up files can be simple like my example below, or a bit more complicated backing up with RSYNC to another server etc. I did not need anything "complicated" but if you require exteral sync, below are several links to get you going :::
# resources
# https://help.ubuntu.com/community/CronHowto
# https://help.ubuntu.com/community/rsync
@yourdesigncoza
yourdesigncoza / FQDN-fully-qualified-domain-name
Last active December 16, 2015 21:09
A fully qualified domain name (FQDN), sometimes also referred as an absolute domain name
# A fully qualified domain name (FQDN), sometimes also referred as an absolute domain name
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# resources :
# http://serverfault.com/questions/367492/how-is-the-fqdn-determined
# http://ubuntuforums.org/showthread.php?t=1189965
# Edit The Hosts file
sudo nano /etc/hosts
@yourdesigncoza
yourdesigncoza / firewall-ufw
Created April 30, 2013 15:52
UFW - Uncomplicated Firewall
# The Uncomplicated Firewall (ufw) is a frontend for iptables and is particularly well-suited for host-based firewalls. ufw provides a framework for managing netfilter, as well as a command-line interface for manipulating the firewall.
# resources
# https://wiki.ubuntu.com/UncomplicatedFirewall
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Enable and configure Firewall - ufw
# ufw firewall is installed by default on Ubuntu 12.04. gufw is a handy GUI frontends for ufw to manage the firewall.
@yourdesigncoza
yourdesigncoza / mysql-commands
Created April 29, 2013 09:26
mySQL simple commands
# Basic Terminal Commands mySQL
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Resources
# http://www.pantz.org/software/mysql/mysqlcommands.html
# Login to your terminal
# Show all DB's
@yourdesigncoza
yourdesigncoza / php-mail-postfix-ubuntu
Created April 26, 2013 18:42
Ubuntu PHP mail() Function with Postfix
# Ubuntu PHP mail
# Ubuntu 12.04 LTS
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Resources
# https://help.ubuntu.com/12.04/serverguide/postfix.html
# http://sourcelibrary.org/2011/08/29/how-to-set-up-the-php-mail-function-on-a-ubuntu-linux-lamp-server/
# http://stackoverflow.com/questions/12083025/xampp-on-ubuntu-server-12-04-with-pear-installed-returns-errors-when-trying-to-u
# http://askubuntu.com/questions/47609/how-to-have-my-php-send-mail
@yourdesigncoza
yourdesigncoza / vstp-very-secure-deamon
Created April 25, 2013 15:27
vsftpd stand for "very secure" and the program was built to have strongest protection against possible FTP vulnerabilities.
# vsftpd - Very Secure Deamon
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Resource
# https://help.ubuntu.com/12.04/serverguide/ftp-server.html
# https://help.ubuntu.com/community/vsftpd
# http://www.noob2geek.com/linux/setup-vsftpd-debian-ubuntu/
@yourdesigncoza
yourdesigncoza / secure-ssh-with-new-port
Created April 25, 2013 13:18
It's best not to use the default port : 22 for ssh, create a new one and sleep better as most DDOS attacks are on port : 22
# Make server more secure by changing default ssh port
# No matter what you do keep your port number safe ... else ...
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh [email protected] where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Open the configuration file
nano /etc/ssh/sshd_config
# Find the following sections and change the information where applicable:
Port [[ 1234 ]]